【发布时间】:2016-05-30 22:48:37
【问题描述】:
已安装Phil Sturgeon Codeigniter Template library
似乎库安装正确,因为我可以使用title()、set_partial() 和set_layout 设置标题。一切正常。但我不能传递任何数据。
如果我在 Controller 中使用 $this->template->title('My Title'); 设置新标题
我可以使用echo $template['title']在任何视图中轻松获得标题
例如,我想传递一条消息:
在视图中:
<?php echo $template['message']; ?>
在控制器中我尝试:
$this->template->set('message', 'My new mess');
$this->template->build('dashboard');
// I get *Undefined index: message* from View
$data['message'] = ['My new mess'];
$this->template->build('dashboard', $data);
// Same *Undefined index: message*
$this->template->build('dashboard', array('message' => 'My new mess'));
// Even this does not work
使用 CI 3。
关于解析器的模板配置设置:
$config['parser_enabled'] = FALSE;
$config['parser_body_enabled'] = FALSE;
好像漏掉了一个小细节。
【问题讨论】:
标签: php codeigniter templates codeigniter-3