首先:我意識到在視圖中使用模型是違背MVC層次結構 - 但這是迄今爲止我找到的最流暢的解決方案。Smarty + CodeIgniter - 正確使用模型的方法
我已將Smarty整合到我的CodeIgniter CMS應用程序中。其功能之一是使用模板以及縮小靜態內容,如CSS和JavaScript。因此,我試圖做這樣的事情在模板文件:
//Adding the static content
<?php
$this->content->css(array('my.css', 'style.css'));
?>
<html>
<head>
//Displaying the now minified static content
<?php $this->content->display() ? >
</head>
</html>
因爲最終的模板應該是由最終用戶或類似的編輯,我認爲這是最簡單的解決方案。
欣賞所有輸入!
模板繼承的效果可以在沒有Smarty幫助的情況下在CI中重新創建。 – 2012-04-22 14:28:05
嗯,我試圖讓設計師直接在模板中輸出他們的樣式,而不需要編輯控制器等。猜猜我必須選擇..謝謝你的回答! – Zar 2012-04-22 14:28:45
@KemalFadillah我知道它可以創建,但在smarty它已經準備好了。而對於我來說,smarty代碼比html代碼中的php代碼更具可讀性(我非常討厭'')。 –
uzsolt
2012-04-22 15:37:29