php - 如何将数据传递到 Codeigniter 模板

标签 php templates codeigniter partials

我正在使用 Phil Sturgeon 的模板库 (http://philsturgeon.co.uk),但在将数据传递到部分时遇到问题。

我可以通过执行 $this->template->title('some title')

来设置标题

我想设置其他属性,例如元描述和元关键字,但我不确定如何将其传递给部分。

最佳答案

尝试构建模板并向其传递您需要的所有数据,例如:

$this->data->myTitle = "Your title";
$this->data->myKeyword = "key1, key2";
$this->template->build('your/view',$this->data);

然后尝试将其使用到您的 View 中:

$myTitle$myKeyword

关于php - 如何将数据传递到 Codeigniter 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9621686/

相关文章:

php - C++转换PHP代码将数字添加到字符串

c++ - VS2015 : Variadic template specialization

php - Codeigniter where_in JSON 列

php - CodeIgniter 中的子文件夹

php - Mysql选择字符串函数问题

javascript - 使用 jQuery 水平滑动的垂直 slider

javascript - meteor 0.8.0 : While building the application: Unexpected closing template tag

javascript - Controller 中的 Codeigniter 奇怪的 ajax 结果

javascript - 如何将选择选项值从 php 代码传递给 Jquery?

c++ - 好友功能和模板