CodeIgniter Forums
[SOLVED] HMVC current module path - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Libraries & Helpers (
+--- Thread: [SOLVED] HMVC current module path (/showthread.php?tid=40108)

[SOLVED] HMVC current module path - El Forum - 03-30-2011

[eluser]Davide Bellini[/eluser]
Hi guys!
I'm integrating Twig Template library in CI with HMVC.

I want insert html template page in module/views folder, like this :

- module_name
- controllers
- module.php
- models
- module_model.php
- views
- module_view.html
- module_view1.html
- ...

How can I retrieve current module "views" path??
I've to set this path in Twig_Loader_Filesystem(array("MODULE_VIEWS_PATH"));


I found a solution for my problem ... I've used :
$module_info = Modules::find($view_name, $this->router->class, 'views/');
$module_view_path = (isset($module_info[0])) ? $module_info[0] : '';
$module_view_name = (isset($module_info[1])) ? $module_info[1] : '';

and retrieve :
[0] => 'C:\WEBROOT_PATH/application/modules/test/views/'
[1] => 'test.html'

Hope this is helpful

[SOLVED] HMVC current module path - El Forum - 04-04-2012


Thank you, your solution is good and is a good start point.

Unfortunately, It's not at all good for me because i need inherit from a base template in all my templates.

I use the CodeIgniter Twig Integration Library (altrano)

My solution was as follows:

- In the config file application/config/twig.php:
$config['template_dir'] = APPPATH.'views'; //For global Templates

- In the library application/libraries/Twig.php:

//HMVC patch by joseayram
$template_module_dir = APPPATH.'modules/'.$this->CI->router->fetch_module().'/views/';
$template_global_dir= $this->CI->config->item('template_dir');
$this->_template_dir = array($template_global_dir, $template_module_dir);
//end HMVC patch
$this->_cache_dir = $this->CI->config->item('cache_dir');

$loader = new Twig_Loader_Filesystem($this->_template_dir);

Hope this is helpful too for someone

[SOLVED] HMVC current module path - El Forum - 06-01-2013

Thank you joseayram,

I changed this line to give me access to the "Contexts" in CIBonfire -

$template_module_dir = APPPATH.'modules/'.$this->CI->router->fetch_module().'/views/'.$this->CI->router->fetch_class();

I used -