Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions: loading modules *dynamically* ?
#1

[eluser]Unknown[/eluser]
Hi guys,

In the App I'm currently developing, I'm facing a weird dilema. I'm trying to load modules dynamically from a variable. What I'm doing now looks like :

Code:
$module_name = "helloworld";
switch($module_name){
    case "helloworld":
        $this->load->module('modules/helloworld');
        $this->helloworld->function()
    break;
}


Is there a smartest way to do it ? I tried :
Code:
$module_name = "helloworld";
$this->load->module('modules/'.$module_name);
$this->$module_name->function()

But of course that is stupid and does not work, but that is the idea.
Thanks in advance for your help !
#2

[eluser]TheFuzzy0ne[/eluser]
Any idea why this doesn't work? What error are you getting, because I think it should work.
#3

[eluser]ImageSmith[/eluser]
Hi cirilo,
I am using the approach you have shown and it is working ok.
One difference though - I load modules like so:
Code:
$module_name = "helloworld";
$this->load->module($module_name);
$this->$module_name->function()




Theme © iAndrew 2016 - Forum software by © MyBB