CI smarty templating with HMVC ? |
[eluser]pedma[/eluser]
Hi, I'm new to CI. It's greate, thanks to all of you, especially the developer. I'm using CI 2.0.2 & smarty 3 templating scripts : http://ilikekillnerds.com/2010/11/using-...i-library/ It works great. CI 2.0.2 works also well with HMVC : https://bitbucket.org/wiredesignz/codeig.../wiki/Home We can combine both, but smarty will get only the last entry of $config['template_directory'] in the config file .../application/config/smarty.php So, if I put like this to .../config/smarty.php config file : $config['template_directory'] = APPPATH."modules/smartytest/views/"; $config['template_directory'] = APPPATH."modules/mytest/views/"; The library will call only the last one. And give error for the first one. I think it will work fine, if the Smarty library : Smarty.php (.../application/libraries/Smarty.php) can define which template_directory is the right path for calling the view. I think we can use array for this, but I don't know how to do it. Any idea ? Please help. Thank you very much. -pedma- [email protected] ============================================================================= The config file : .../config/smarty.php is like this : <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); $config['template_directory'] = APPPATH."modules/mytest/views/"; $config['compile_directory'] = APPPATH."cache/smarty/compiled"; ... etc ... The library file : ..../libraries/Smarty.php is like this : <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once APPPATH."third_party/Smarty/Smarty.class.php"; class CI_Smarty extends Smarty { public function __construct() { parent::__construct(); // Store the Codeigniter super global instance... whatever $CI = get_instance(); $CI->load->config('smarty'); $this->template_dir = config_item('template_directory'); $this->compile_dir = config_item('compile_directory'); $this->cache_dir = config_item('cache_directory'); $this->config_dir = config_item('config_directory'); $this->template_ext = config_item('template_ext'); $this->exception_handler = null; // Add all helpers to plugins_dir $helpers = glob(APPPATH . 'helpers/', GLOB_ONLYDIR | GLOB_MARK); foreach ($helpers as $helper) { $this->plugins_dir[] = $helper; } // Should let us access Codeigniter stuff in views $this->assign("this", $CI); } } |
Messages In This Thread |
CI smarty templating with HMVC ? - by El Forum - 07-19-2011, 11:13 PM
CI smarty templating with HMVC ? - by El Forum - 07-20-2011, 01:34 AM
CI smarty templating with HMVC ? - by El Forum - 07-20-2011, 03:22 AM
|