在smarttemplate的使用过程中,看看我这样写哪里错了?运行的结果不太正确。..............................

ilovewenxue 2005-07-11 02:52:22
//index.php
<?
require_once 'class.smarttemplate.php';
$tpl=new SmartTemplate('header.htm'); //header.htm 为网站头部
$tpl->assign('webname','网站名称');
$tpl->output();

$tpl3=new SmartTemplate('center.htm'); //center.htm为网站中部
$tpl3->assign('content','内容......');
$tpl3->output();

$tpl2=new SmartTemplate('footer.htm'); //footer.htm为网站尾部
$tpl2->assign('banquan','ZZ');
$tpl2->output();
?>
...全文
100 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ilovewenxue 2005-07-11
  • 打赏
  • 举报
回复
我怎么看不出模板的好处了啊
YT7260 2005-07-11
  • 打赏
  • 举报
回复
搭车问一下,smarttemplate产生的在temp里的临时文件,它不会自己删吗?难道还需写个定时删除的程序?
ice_berg16 2005-07-11
  • 打赏
  • 举报
回复
多套模板一起使用?不可能吧。
用户选择风格后,将该风格选择写入配置文件或数据库,然后根据用户选择的风格读取相应风格下面的模板.
例如:
define( "APP_STYLE", "default" );
用户修改风格后可能变成
define( "APP_STYLE", "styl2" );

下面的定义是
template_dir => "./templates/" . APP_STYLE,
ilovewenxue 2005-07-11
  • 打赏
  • 举报
回复
先谢谢

有多套模板,所以template_dir可以有多个模板目录
比如
template_dir => "./templates/default"
template_dir => "./templates/styl1"
template_dir => "./templates/styl2"
......

如果把这个$_CONFIG数组写到每个程序页面中,觉得是不是有点麻烦了
xuzuning 2005-07-11
  • 打赏
  • 举报
回复
1、是的
2、意义不清楚
ilovewenxue 2005-07-11
  • 打赏
  • 举报
回复
非常感谢唠叨的解答-------------------------------------------------------
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢

问题一:
模板文件这样写吗?
//tpl.htm
<?php include "header.php"; ?>
......
{name}is good boy.
......
<?php include "footer.php"; ?>

问题二:
在$_CONFIG数组中,template_dir指定的模板目录为default,但是这个default是变化的,比如有时候就是“style1",那么这个$_CONFIG数组应该怎样写,或者写到哪里比较合理一点啊?
$_CONFIG = array(
smarttemplate_compiled => "./temp",
smarttemplate_cache => "./cache",
cache_lifetime => 600,
template_dir => "./templates/default"
);
xuzuning 2005-07-11
  • 打赏
  • 举报
回复
主体模板文件
<?php include "header.php"; ?>
模板内容
<?php include "footer.php"; ?>
ilovewenxue 2005-07-11
  • 打赏
  • 举报
回复
多谢老大,头部尾部的包含文件应该怎样写比较合理啊?我觉得我这样的写法,总是觉得有点问题
xuzuning 2005-07-11
  • 打赏
  • 举报
回复
在class.smarttemplate.php
中找到
unset ($_top);
只有一处!!!
修改为
unset ($GLOBALS['_top']);

如不想这样做,也可以
require_once 'class.smarttemplate.php';
$tpl=new SmartTemplate('header.htm'); //header.htm 为网站头部
$tpl->assign('webname','网站名称');
$tpl->output();
unset($_top);

$tpl3=new SmartTemplate('center.htm'); //center.htm为网站中部
$tpl3->assign('content','内容......');
$tpl3->output();
unset($_top);

$tpl2=new SmartTemplate('footer.htm'); //footer.htm为网站尾部
$tpl2->assign('banquan','ZZ');
$tpl2->output();

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧