[eluser]Steve Goodwin[/eluser]
So I'm creating a CMS which loads HMVC modules as modules on a page from a database.
Modules can be for example:
- Content
- Product
- Product Categories
etc etc
I am using this code in order to loop through the modules associated with that page in order to pull them out and run them on the page:
Code:
foreach($modules as $module)
{
$this->load->module($module->module);
$this->{$module->module}->index(array('uri' => $uri->id, 'content' => $module->content_id));
}
Obviously this loops through the result set from my query.
The problem isn't here, its when i try to use this in conjunction with Phils template library I hit a problem. Phils library is trying to use the code from the HMVC library located in "MX/Router.php" on line 40:
Code:
public function fetch_module() {
return $this->module;
}
This only gets set when running a module directly as "/{module-name}/" it doesn't get set for aliases therefore causing me a problem when dynamically loading modules, the views cannot be found.
Phils code is trying this method to load:
Code:
$theme_views = array(
$this->_theme . '/views/modules/' . $this->_module . '/' . $view,
$this->_theme . '/views/' . $view
);
This is trying to pick up from the local class property defined in the "Template.php" library which is set in the __construct() method when the class loads:
Code:
// Modular Separation / Modular Extensions has been detected
if (method_exists( $this->_ci->router, 'fetch_module' ))
{
$this->_module = $this->_ci->router->fetch_module();
}
Obviously when running from an alias or like I am via code it doesn't seem to set the $this->module property meaning the views won't load due to an unknown located.
Has anyone found or can suggest a fix for this? Or is there a different method to retrieve the current running module?
Thanks
Steve