1) smarty.class.php
var $config_dir = 'configs';
2) 编辑init.inc.php
$tpl->config_dir = ‘configs’;
3)到web跟文档目录之外位置新建文件configs
4)建立文件configs/foo.conf
5)编辑foo.conf文件内容
#表示注释行
自定义变量名=该变量的值
6)打开*.html(tpl)模板文件
l 加载配置文件 ---使用smarty的内建函数 config_load
<{cofig_load file=”foo.conf”}>
使用变量<{#来自于配置文件的变量名#}>
如果需要将内容放到不同模板文件中,定义节(局部变量)
[节名称]
3) smarty保留变量
PHP中的超全局变量数组
$_GET
第一种:
url:http://localhost/b.php?page=10
*.php
$tpl->assign(“page”,$_GET[‘page’]);
*.html(tpl)
<{$page}>
使用保留变量显示超全局数组
第二种:$smarty.超全局变量数组名.元素的下标名