Php 使用Smarty 3、编码点火器2和HMVC以及Smarty';什么是遗产?
我正在使用CodeIgniter、和Smarty 默认情况下,Smarty工作正常,但是如果我尝试使用Smarty的继承功能(Php 使用Smarty 3、编码点火器2和HMVC以及Smarty';什么是遗产?,php,codeigniter,extend,hmvc,smarty3,Php,Codeigniter,Extend,Hmvc,Smarty3,我正在使用CodeIgniter、和Smarty 默认情况下,Smarty工作正常,但是如果我尝试使用Smarty的继承功能({extends file=“master.tpl”}),那么就会遇到问题 扩展功能不会在模块视图文件夹中查找扩展文件(在上述情况下为master.tpl),而是只在application/views/文件夹中查找,如果找不到,则抛出错误 我可以将APPPATH.“modules/smartytest/views”添加到smarty配置文件中的$config['templ
{extends file=“master.tpl”}
),那么就会遇到问题
扩展功能不会在模块视图文件夹中查找扩展文件(在上述情况下为master.tpl
),而是只在application/views/
文件夹中查找,如果找不到,则抛出错误
我可以将APPPATH.“modules/smartytest/views”
添加到smarty配置文件中的$config['template\u directory']
数组中。但这会为它首先检查文件的数组中的每个项抛出一个错误<代码>filemtime():应用程序/views/master.tpl的stat失败
这就增加了一个问题,如果我有三个模块,所有的阵列和模块都有一个master.tpl,那么无论我调用哪个模块,扩展都会加载找到的第一个模块
那么,有没有办法让smarty的extend函数与HMVC模块配合良好?啊,找到了一个可行的解决方案 在
My_Parser.php
中编辑第30行的块,使其显示:
// Modular Separation / Modular Extensions has been detected
if (method_exists( $this->CI->router, 'fetch_module' ))
{
$this->_module = $this->CI->router->fetch_module();
//add the current module view folder as a template directory
if ($this->_module !== '')
$this->CI->smarty->addTemplateDir(APPPATH."modules/".$this->_module.'/views');
}
此方法的一个缺点是smarty会先查看应用程序/视图文件夹,再查看模块视图文件夹。如果有人知道解决方案,那就太棒了。问题是CI没有检查错误报告()返回0,因为Smarty使用@control运算符: 因此,在函数“\u exception\u handler”的顶部添加一行:
if(error_reporting()==0)返回代码>
调用“\u exception\u handler”函数(第469行)中的“Common.php”文件,或者在index.php文件中调用“CodeIgniter.php”之前创建自己的同名函数
最好的 受保护的函数\u查找\u视图($file){//Ye ol'faith views folder$view_folder=APPPATH。'views//'//我们的HMVC模块的位置$modules_folder=APPPATH。'modules//'//最终路径$Final_path=FALSE;//添加以下行!!!!!!!!!!!!!!!$this->_module=$this->CI router->fetch_module;//如果($this->\u module!=='')我有类似的问题,但是如果你能解决的话,我的CI smarty没有使用HMVC,请确保我们有一个模块。赏金是你的。还有一段时间。