码迷,mamicode.com
首页 > 其他好文 > 详细

Smarty模板的学习_2

时间:2017-05-30 20:55:14      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:font   width   border   etc   dir   ble   order   conf   round   

使用配置文件给变量赋值

一,在配置类中设置配置文件的目录名字和路径

$smarty->setConfigDir(ROOT."/configs");

二,创建目录文件  configs,里面再创建一个后缀是 .conf  的文件

然后再配置文件中定义变量,如下所示

bgcolor=red;
width=100px;
height=200px;
color=black;
border=‘2‘;

三,在使用模板的tpl文件的前头引入配置文件

<{config_load file="config.conf"}>

 

四,调用文件的变量,格式是<{#变量名#}>

<body style="background-color:<{#bgcolor#}> ">
<table border="<{#border#}>"  style="width: <{#width#}>;height: <{#height#}>">

 

Smarty模板的学习_2

标签:font   width   border   etc   dir   ble   order   conf   round   

原文地址:http://www.cnblogs.com/zhengweizhao/p/6921089.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!