Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - Modules::load() not working for me
#1

[eluser]Ejade[/eluser]
Howdy,
I'm close to having Modular Extensions fully working. Just can't make this one thing work.
Modules::load()

Any help or clarification would be appreciated.

Code:
class Blog extends MX_Controller {

    function __construct()
    {
        parent::__construct();    
    }

    function index()
    {
        $this->load->module('welcome/welcome_controller'); //Works great
       //modules::load('welcome'); GIVES ERROR
    
        $this->welcome_controller->index();
        
    }
}


A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI::$welcome_controller

Filename: MX/Controller.php

Line Number: 57

Fatal error: Call to a member function index() on a non-object in /Users/iMac/Sites/test2/application/modules/blog/controllers/blog.php on line 16
#2

[eluser]wiredesignz[/eluser]
You do not need to load a module before calling Modules::run()

Modules::run() returns the output from the module it does not output anything itself.

EDIT:
I see you have edited your question after I posted this answer.
#3

[eluser]Ejade[/eluser]
AAAH yeah....
I figured that out and realized I posted the wrong question.
Very little sleep I guess.

The actual question has been edited and is about modules::load()

Thanks and sorry about the mix up.

Ej
#4

[eluser]wiredesignz[/eluser]
You will need to assign to a variable if you use Modules::load()

Code:
$module = Modules::load('welcome/welcome_controller');
#5

[eluser]Ejade[/eluser]
Bizarre....

Code:
class Blog extends MX_Controller {

    function __construct()
    {
        parent::__construct();    
    }

    function index()
    {
        
        $module = Modules::load('welcome/welcome_controller');    
        $this->welcome_controller->index();    
        
    }
}

Gives Error

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI::$welcome_controller

Filename: MX/Controller.php

Line Number: 57


Fatal error: Call to a member function index() on a non-object in /Users/iMac/Sites/test2/application/modules/blog/controllers/blog.php on line 16
#6

[eluser]Ejade[/eluser]
Okay got it working
used

Code:
$module->index();

instead of
Code:
$this->welcome_controller->index();

FINAL CODE THAT WORKED FOR ME

Code:
class Blog extends MX_Controller {

    function __construct()
    {
        parent::__construct();    
    }

    function index()
    {
        
        $module = Modules::load('welcome/welcome_controller');
        
        $module->index();
        
    }
}

Thanks wiredesignz for the fast response.




Theme © iAndrew 2016 - Forum software by © MyBB