配置文件

1、配置文件有利于设计者管理文件中的模板全局变量

2、配置文件是通过内建函数载入到模板中 <{  config_load file="文件地址"  }>

                 foo.conf:                                           //#注释部分

                       pageTitle = "This is mine"        //当变量中有空格时,需要用引号引着,没有空格时 ,可不引 。" " " 是定界符,定界符中可以是任意格式

                       bodyBgColor = "#eeeeee"         

                       tableBorderSize = "3"

                       tableBgColor = "#bbbbbb"

                       rowBgColor = "#cccccc"

                        [mycolor]                        // [  ]是section的内容  当写section时,需顶格写

                       bgcolor = #000000

            index.tpl:

                      {config_load file="foo.conf" section='mycolor'}

                     <html>

                         <title>{#pageTitle#}</title>

                      <body bgcolor="{#bodyBgColor#}">

                      <table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">

                          <tr bgcolor="{#rowBgColor#}">

                              <td>First</td><td>Last</td><td>Address</td>

                         </tr>

                       </table>

                    </body>

               </html>

             index.tpl:

                    {config_load file="foo.conf"}

                        <html>

                              <title>{$smarty.config.pageTitle}</title>

                          <body bgcolor="{$smarty.config.bodyBgColor}">

                              <table border="{$smarty.config.tableBorderSize}" bgcolor="{$smarty.config.tableBgColor}">

                                 <tr bgcolor="{$smarty.config.rowBgColor}"

                                         <td>First</td><td>Last</td><td>Address</td>

                                        </tr>

                               </table>

                   </body>

                   </html>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值