Jump to content

Upcoming version - changes to modules


Nabeel

Recommended Posts

  • Administrators

Modules have been overhauled, a-la CakePHP-esque style controllers.

For instance, in the past there needed to be a router inside the "Controller" function:

For instance, the URL

index.php/mymodule/doaction

Previously, the code for this would be:

<?php
class MyModule
{
    public function Controller()
    {
        switch($this->get->page)
        {
            case 'doaction':
                ....
            break;
        }
    }
}
?>

Has now been simplified to:

<?php
class MyModule
{
    public function index()
    {
        
    }
    
    
    public function doaction()
    {
        ...
    }
}

With the index() function replacing the Controller() function, and then the doaction() function acting as the action.

From now on, the parameter after the module name, will be the function that's called inside the module.

index.php/test/callingme

<?php

class test
{
    public function callingme()
    {
        ...
    }
}

This simplifies debugging. In addition, parameters can more easily be passed:

index.php/test/callingme/apples/oranges

<?php
class test
{
    public function callingme($parameter1='', $parameter2='')
    {
        echo "{$parameter1} and {$parameter2}";
        // Will echo "apples and oranges"
    }
}

These changes will be made available from the next version. The native modules have been updated to use this new code. Modules will have to be updated to use this code as well

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...