【发布时间】:2013-03-01 08:56:12
【问题描述】:
我开始使用 Codeigniter 框架,我想使用 Phil Sturgeon 的 Codeigniter 模板:
http://github.com/philsturgeon/codeigniter-template/zipball/master
我按照下面的安装步骤:
- 下载最新版本
- 将此包中的文件复制到应用程序文件夹中的相应文件夹
- 从
config/template复制到相应的位置(在config目录中) - 从
libraries/template复制到相应的位置(在库目录中。) - 加载模板(在
config/autoload.php写$this->load->library('template');)
- 从
最后我在控制器中使用这个模板,如下所示:
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,我有layouts\default.php,我写了
{{ template:title }}
.. 在default.php.
但我无法访问 title 变量。我做错了什么,或者没有做什么?
我添加了这个部分,我可以在 default.php 中使用 $template['title'] 但我不能使用解析器来显示我的变量。
【问题讨论】:
-
我对您的问题进行了大量修改,请查看version history 了解我是如何使用格式的,并在以后将其作为指南。
-
感谢蒂姆的编辑
标签: php codeigniter templates