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下的模板呢

解决方案 »

  1.   

     $smarty->compile_dir = './templates_c/';      //设置编译目录
     
     $smarty->cache_dir = './caches/';              //缓存文件夹//这2个设置可写入的权限
      

  2.   

    图片 没显示 祖目录是 lib_sys 其下 有admin , smarty, cache ,templates, compile_c 这几个目录
      

  3.   

    一、打开我的电脑,在菜单栏上点“工具”>>“文件夹选项”>>“查看”>>“使用简单文件共享”取消选中二、在你需要设置写入权限的文件夹上点“右键”>>“属性”>>“安全”>>“添加”>>“everyone”>>“选择的相应的控制权限”如果你的是win2000或是win2003,则直接操作第二步即可。
    linux chmod 777 -R filename
      

  4.   


    怎么设置路径,才可以在admin下使用templates下的模板呢
      

  5.   

    路径啊,你 smarty 配置模块路径是没错。
    但你的 php 包含 smarty 就错了,看看php的包含目录就知了。
      

  6.   


    把$smarty->display('../templates/test.htm');
    改成$smarty->display('test.htm');
    也是一样
      

  7.   


    //使用绝对+相对路径
    $path=dirname(__FILE__);
     $smarty->template_dir = $path.'/templates/';        //设置模板目录 $smarty->compile_dir = $path.'/templates_c/';      //设置编译目录
     
     $smarty->cache_dir = $path.'/caches/';              //缓存文件夹//后面的可以跟你之前的一样使用