smarty_inc.php代码如下
<?php
include_once('smarty/Smarty.class.php'); // 引入Smarty类
$smarty = new Smarty(); //实例化Smarty类
$smarty->config_dir = 'smarty/Config_File.class.php'; //目录变量
$smarty->caching = false; //缓存设置
$smarty->template_dir = './templates/'; //设置模板目录 $smarty->compile_dir = './templates_c/'; //设置编译目录
$smarty->cache_dir = './caches/'; //缓存文件夹
/**设置左右边界符**/
$smarty->left_delimiter = '{'; //左边界
$smarty->right_delimiter = '}'; //右边界
?>我在admin目录下建了一个test.php文件调用smarty_inc.php,代码如下<?php
include_once('../smarty_inc.php');$smarty->assign("te",'这是一个测试');
$smarty->display('../templates/test.htm');
?>然后再templates下建了test.htm,代码如下
<p>{$te}<p>错误提示:Warning: Smarty error: unable to read resource: "../templates/test.htm" in D:\wamp\www\lib_sys\smarty\Smarty.class.php on line 1095
请问我要怎么样才可以在admin里使用templates下的模板呢
<?php
include_once('smarty/Smarty.class.php'); // 引入Smarty类
$smarty = new Smarty(); //实例化Smarty类
$smarty->config_dir = 'smarty/Config_File.class.php'; //目录变量
$smarty->caching = false; //缓存设置
$smarty->template_dir = './templates/'; //设置模板目录 $smarty->compile_dir = './templates_c/'; //设置编译目录
$smarty->cache_dir = './caches/'; //缓存文件夹
/**设置左右边界符**/
$smarty->left_delimiter = '{'; //左边界
$smarty->right_delimiter = '}'; //右边界
?>我在admin目录下建了一个test.php文件调用smarty_inc.php,代码如下<?php
include_once('../smarty_inc.php');$smarty->assign("te",'这是一个测试');
$smarty->display('../templates/test.htm');
?>然后再templates下建了test.htm,代码如下
<p>{$te}<p>错误提示:Warning: Smarty error: unable to read resource: "../templates/test.htm" in D:\wamp\www\lib_sys\smarty\Smarty.class.php on line 1095
请问我要怎么样才可以在admin里使用templates下的模板呢
解决方案 »
- 如何用php socket模仿浏览器啊
- php中执行linux命令失败?
- 为memcached开发的tag功能【支持php扩展】
- 求几道面试题(急)
- PHP的电子购物网站,平均每天总页面点击5W次,有必要专用服务器吗?
- 请问各种域名都是归谁管的?比如www.???.net.cn归whois.cnnic.net.cn管理,www.????.com归whois.nsiregistry.net管理
- 寻求一种锁定方式,有没有同一进程可以写,但是其他进程只允许读的锁定方式
- 域名解析成IP?
- 请问:netbean开发php按什么快捷键可以如何添加多行文档性注释
- 求大神帮忙看代码哪里错了,错误显示的是 Parse error: syntax error, unexpected end of file in D:\XAMP
- php怎么模拟post数据,然后保存cookie在客户端
- PHP+MYSQL 如何提高查询速度
$smarty->cache_dir = './caches/'; //缓存文件夹//这2个设置可写入的权限
linux chmod 777 -R filename
怎么设置路径,才可以在admin下使用templates下的模板呢
但你的 php 包含 smarty 就错了,看看php的包含目录就知了。
把$smarty->display('../templates/test.htm');
改成$smarty->display('test.htm');
也是一样
//使用绝对+相对路径
$path=dirname(__FILE__);
$smarty->template_dir = $path.'/templates/'; //设置模板目录 $smarty->compile_dir = $path.'/templates_c/'; //设置编译目录
$smarty->cache_dir = $path.'/caches/'; //缓存文件夹//后面的可以跟你之前的一样使用