Skip to content

Modular Extensions FAQ

Derek Jones edited this page Jul 5, 2012 · 22 revisions

Category:Library::HMVC

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

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

<?php echo modules::run('module/controller/method') ?>

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:

<?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.

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

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

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

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 subdirectory of a module (system/application/modules/mymodule/models/mymodelname.php)

Clone this wiki locally