我開始使用笨框架,我想用菲爾鱘魚的笨模板:如何使用philsturgeon Codeigniter模板?
http://github.com/philsturgeon/codeigniter-template/zipball/master
我也跟着像下面的安裝步驟:
- 下載最新版本的
- 將此包中的文件複製到應用程序文件夾中的相應文件夾中
- 從012複製到相應的地方(在config目錄下。)從
libraries/template
- 複製到相應的地方(在圖書館目錄。)
- 加載模板(在
config/autoload.php
寫$this->load->library('template');
)
- 從012複製到相應的地方(在config目錄下。)從
,並在結束時,我在控制器中使用此模板,如下所示:
public function index() {
$data["header"] = "ayastr";
$data["content"] = "content1";
$this->template->enable_parser(TRUE);
$this->template->enable_parser_body(TRUE);
//$this->template->set('title', "test");
$this->template->title("aya");
$this->template->build('example_page_view', $data);
}
在視圖example_page_view.php
中,I h AVE layouts\default.php
,我寫
{{ template:title }}
。在default.php
。 但我無法訪問標題變量。我做錯了什麼,或者不行? 我在default.php
中添加了我可以使用$ template ['title']的這一節,但是我不能使用解析器來顯示我的變量。
我已經對您的問題進行了相當多的修改,請查看[版本歷史記錄](http://stackoverflow.com/posts/15153889/revisions)以查看我如何使用格式,並將其作爲未來的指南。 – 2013-03-01 09:02:53
感謝Tim的編輯 – aya 2013-03-01 09:10:43