【发布时间】:2011-01-09 20:03:30
【问题描述】:
我试图弄清楚如何使用 php Smarty 模板引擎将页面保存在子目录(类别)中。
例如,如果我的结构是:
index.php
category1/page1.php
category2/page2.php
等等
根 index.php 渲染得很好
使用默认的 smarty 设置:
<?php
require_once('lib/smtemplate.php');
$data = array(
'meta_keywords' =>'key1, key2',
'category' =>'category1'
);
$tpl = new SMTemplate();
$tpl->render('page', $data);
?>
但是如果我将它复制到子目录中,即使我更改为它也会中断
require_once('../lib/smtemplate.php');
到目前为止我还没有找到解决方案。
感谢您的帮助。 谢谢。
【问题讨论】:
-
您的模板文件在哪里?
SMTemplate的代码是什么?您是否设置了 Smarty 对象的正确template_dir属性?在提问之前,您是否费心阅读文档 [smarty.net/docs/en/variable.template.dir.tpl]?
标签: php smarty template-engine