Php Smarty,子目录中的页面

Php Smarty,子目录中的页面,php,smarty,template-engine,Php,Smarty,Template Engine,我试图弄清楚如何使用php Smarty模板引擎在子目录(类别)中保存页面 例如,如果我的结构是: index.php category1/page1.php category2/page2.php 等等 root index.php呈现得很好 使用默认smarty设置: <?php require_once('lib/smtemplate.php'); $data = array( 'meta_keywords' =>'key1, key2', 'catego

我试图弄清楚如何使用php Smarty模板引擎在子目录(类别)中保存页面

例如,如果我的结构是:

index.php
category1/page1.php
category2/page2.php
等等

root index.php呈现得很好

使用默认smarty设置:

<?php 
require_once('lib/smtemplate.php');

$data = array(
    'meta_keywords' =>'key1, key2',
    'category' =>'category1'
    );

$tpl = new SMTemplate();
$tpl->render('page', $data);

?>
到目前为止,我还没有找到解决办法

谢谢你的帮助。 thx.

定义基本路径:

define("BASEPATH", "/var/www/yoursite/");
包括:

require_once(BASEPATH.'lib/smtemplate.php');

只是尝试了一下,但没有成功。下面是我得到的错误:致命错误:未捕获的异常“SmartyException”,在E:\wamp\www\smarty\lib\smarty\sysplugins\smarty_internal_template.php:163堆栈跟踪:#0 E:\wamp\www\smarty\lib\smarty\sysplugins\smarty_internal_template.php(541):smarty_internal__template->isExisting(true)#1 E:\wamp\www\smarty\lib\smarty\smarty.class.php(337):smarty\u Internal_Template->getRenderedTemplate()#2 E:\wamp\www\smarty\lib\smtemplate.php(30):smarty->fetch('hello.tpl')或我使用的shell define(“BASEPATH”、“/var/www/yoursite/”;也通过所有配置文件?您应该。但是找到“hello.tpl”也有困难。。。我认为最好的解决方案是“修复路径”:Dmy root index.php文件与hello.tpl呈现得很好,所以我简直不敢相信Smarty无法管理子目录中的页面。如果您设置了从相对路径加载的内容,恐怕您会遇到问题。从不同的子区包含总是一件事,对不起,但事实就是这样。。。。例如,也适用于模板\u c dir…模板文件位于哪里?您的SMTemplate的代码是什么?您是否正确设置Smarty对象的
template\u dir
属性?在询问之前,您是否费心阅读文档[]?
require_once(BASEPATH.'lib/smtemplate.php');