[英]How can I save a template and download it from the database using smarty template engine
我很难将模板保存到数据库并下载内容以使用Smarty查看。
我遵循Smarty.net上的教程,了解如何制作自定义检索类型。
我原来的方法是将tpl标记保存到数据库,然后下载它,并将其作为变量传递给一个聪明的分配变量,然后在我的text.pl中执行类似{$ source}的操作
但这会将其解析为字符串,并且聪明的不会编译它。
smarty网站上的教程没有帮助,只是让我有更多问题...
这是我根据教程尝试过的
function db_get_template($tpl_name, &$tpl_source, &$s)
{
$tpl_name = "index.tpl";
$tpl_source = nl2br($defaults->get_default_theme('theme_data'));
return true;
}
function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
{
$tpl_timestamp = (int)time();
//$tpl_timestamp = (int)$defaults->get_default_theme('modified_on');
return true;
}
function db_get_secure($tpl_name, &$smarty)
{
// assume all templates are secure
return true;
}
function db_get_trusted($tpl_name, &$smarty)
{
// not used for templates
}
$s->registerResource("db", array(
"db_get_template",
"db_get_secure",
"db_get_trusted"
));
$s->display("db:index.tpl");
我不确定db:index.tpl是从哪里提取的。 我不知道标记应该在哪里加载...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.