我使用Code Igniter,HMVC library和Smarty與this library。將Smarty 3,Code Igniter 2和HMVC與smarty的繼承一起使用?
默認情況下,Smarty工作正常,但如果我嘗試使用smarty的繼承功能({extends file="master.tpl"}
),那麼我們遇到問題。
擴展功能不會在擴展文件的模塊視圖文件夾中查找(在上面的案例中爲master.tpl
),而是僅在application/views/
文件夾中查找,並在找不到該錯誤時引發錯誤。
我可以將APPPATH."modules/smartytest/views"
添加到smarty配置文件中的$config['template_directory']
數組中。但是它會爲數組中的每個項目首先檢查該文件引發錯誤。 filemtime(): stat failed for application/views/master.tpl
這還有個問題,如果我有三個模塊,所有的數組和模塊都有一個master.tpl,那麼無論我調用哪個模塊擴展它都會加載找到的第一個模塊。
那麼,有沒有辦法讓smarty的擴展函數與HMVC模塊很好地配合?
保護功能_find_view($文件){Yeo ol'忠實的意見文件夾 $ view_folder = APPPATH。 '視圖/';我們的HMVC模塊 $ modules_folder = APPPATH。 '模塊/'; //最終路徑 $ final_path = FALSE; //添加以下行!!!!!!!!!!!!!! $ this - > _ module = $ this-> CI-> router-> fetch_module(); //確保我們有一個模塊 如果($ this - > _ module!==''){ –
Y我的評論被截斷 – Hailwood
我有一種相同類型的問題,但沒有使用HMVC與我的CI聰明如果你能解決它的賞金是你的。有一段時間還在。 http://stackoverflow.com/questions/25541382/smarty-templates-with-codeigniter-cant-load-template-when-too-many-directories –