• Smarty从配置文件读取的变量


    从配置文件读取的变量

    配置文件中的变量需要通过用两个"#"或者是smarty的保留变量 $smarty.config.来调用(下节将讲到)
    第二种语法在变量作为属性值并被引号括住的时候非常有用.
    (译注:举个例子 {include file="#includefile#"} 这样#includefile#将被当作字符处理,而不表示配置文件变量,
        但可以这样表示 {include file="`$smarty.config.includefile`"}不要忘了加``)


    例 4-5.从配置文件引用的变量

     
    foo.conf:
    
    pageTitle = "This is mine"
    bodyBgColor = "#eeeeee"
    tableBorderSize = "3"
    tableBgColor = "#bbbbbb"
    rowBgColor = "#cccccc"
    
    index.tpl:
    
    {config_load file="foo.conf"}
    <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: (alternate syntax)
    
    {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>
    
    
    OUTPUT: (same for both examples)
    
    <html>
    <title>This is mine</title>
    <body bgcolor="#eeeeee">
    <table border="3" bgcolor="#bbbbbb">
    <tr bgcolor="#cccccc">
    	<td>First</td>
    	<td>Last</td>
    	<td>Address</td>
    </tr>
    </table>
    </body>
    </html>
  • 相关阅读:
    UDP案例_在线咨询
    MFC对话框水平和垂直滚动条功能
    对话框中滚动条
    ON_COMMAND_RANGE 多个按钮响应一个函数
    char**赋值
    MFC如何使dialog对话框置顶
    如何让CListBox控件滚动条自动向下滚动?
    不带,以及带参数,带返回值的Lambda表达式
    JAVA学习_多线程技术
    最烦有些技术帖上来就放代码
  • 原文地址:https://www.cnblogs.com/danmao/p/4297505.html
Copyright © 2020-2023  润新知