在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();
中找到
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();
<?php include "header.php"; ?>
模板内容
<?php include "footer.php"; ?>
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢问题一:
模板文件这样写吗?
//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"
);
比如
template_dir => "./templates/default"
template_dir => "./templates/styl1"
template_dir => "./templates/styl2"
......如果把这个$_CONFIG数组写到每个程序页面中,觉得是不是有点麻烦了
用户选择风格后,将该风格选择写入配置文件或数据库,然后根据用户选择的风格读取相应风格下面的模板.
例如:
define( "APP_STYLE", "default" );
用户修改风格后可能变成
define( "APP_STYLE", "styl2" );下面的定义是
template_dir => "./templates/" . APP_STYLE,