Skip to content

Modular Extensions FAQ

World Wide Web Server edited this page Jul 4, 2012 · 22 revisions

Category:Library::HMVC

[b]Q: What does the abbreviation ME stand for?[/b] [b]A:[/b] In forum threads and the wiki ME is used as a abbreviation for Modular Extensions.

[b]Q: How can I load a module from within a view?[/b] [b]A:[/b] Put the following line in your view file

[code] <?php echo modules::run('MODULE', $data, 'METHOD') ?> [/code]

Explanation: MODULE = The name of the module you want to use (required). Example: 'blog' $DATA = The data which will be available in the method. This can be either a string or an array. (optional) METHOD = The controller->method you want to use. The default method is index. (optional). Example: 'blog_read'

You may return a value as the output of a module controller or you can output a view or simply use echo, because the output is buffered and returned it can be used as needed.

Example: [code] <?php class Blog extends Controller {

function blog()
{
    parent::Controller();   
}

function blog_read($id)
{
    $data['title'] = 'Title '. $id;

    $this->load->view('blog_read',$data);  //return is NOT required for views.

    return $some_data;    //return CAN be used if needed.
}

} [/code]

[b]Q: How can I load a model in a controller of a module?[/b] [b]A:[/b] Take the following code as an example:

[code] // Loading a model $this->load->model('mymodelname'); // Using a model $this->mymodelname->function(); [/code]

mymodelname = The name of the model you want to load. function = The function of the model you want to use. The model can be stored in the application folder (system/application/models/mymodelname.php) or in the models folder of a module (system/application/modules/mymodule/models/mymodelname.php)

Clone this wiki locally