smarty里面的路径设置
发布于 2005-10-06 14:52 1 阅读:18,364 评论:1 标签: smarty
本站帖子:http://unclemoon.512j.com/bbs/look.php?id=64

原帖子如下:
http://www.phpx.com/happy/top108021.wsdl


PHP代码:
--------------------------------------------------------------------------------
$smarty->template_dir = "./templates";//设置模板目录
$smarty->compile_dir = "./templates_c"; //设置编译目录

--------------------------------------------------------------------------------


偶不太明白后面的注解

据说模板目录就是自己做那个模板
编译目录就是php把模板解析过之后存放的目录

偶现在有两个大目录,一个是smarty,里面有header.tpl,foot.tpl,index.tpl
index.tpl包含前两个,最后用index.php输出
还有一个是class,就是模板的系统文件

偶应该怎么设置?
上面意思还要设置一个目录给用户看?(编译目录)



终于弄好了

偶是这样设置的

主目录下设置calss,templates,configs,cache,templates_c五个目录

作用如下:

calss:里面放置从http://smarty.php.net/download.php下载的最新文件。下载的文件里面有好几个目录。只取出libs目录里面的文件就可以了。它是整个smarty的核心。这个class可以换其他名字,但一定要和其他文件保持路径关系。下面几个也一样。

templates:里面放置你你做好的.tpl文件,即你的模板文件

templates_c:这个里面不放东西,作用是当用户看你页面时系统生成一个文件,作用嘛,哎……刚开是学,偶说不清楚!它就是高手们所说的存放编译文件吧

configs:用来存放一些配置信息。偶现在还没放东西

cache:用来存放缓存。不知道是什么意思。偶现在还没放东西

最后,.php文件放在主目录下。用户访问你这个页面后,templates_c里面会自动生成文件
cache是用来放生成的静态页面,可通过以下方式使用:

http://club.phpe.net/index.php?act=ST&f=15&t=11091&hl=&s=

bennybi给偶的回复:

cache是用来放生成的静态页面,可通过以下方式使用:

... //变量声明
$smarty1->caching = 2; // 2, lifetime is per cache , 0, no caching
$smarty1->cache_lifetime = 360;
if(!$smarty1->is_cached($APP_SYS_PARAM_CFG['SITE_FORE'].'/index.html')){
... //模板变量声明
}

/*-----------显示模板-----------------------*/
$smarty1->display($APP_SYS_PARAM_CFG['SITE_FORE'].'/index.html');

说明:
1. $APP_SYS_PARAM_CFG['SITE_FORE']是前台模板路径;
2. 在缓存时间之内,访问主页时,模板引擎会调用之前在cache/里生成的静态页面

by 芽雨 2005-10-10 21:14:00
Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 154

Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 172