Get Smarty

Donate

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap glasses from Cheapglasses123.com and save up to 80%.

Where to buy prescription glasses? EyewearCanada.com is your best choice!

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Shop for 2018 World Cup Football Boots Online sale at guthjcc.com

Browse best 2018 world cup soccer cleats and shoes from SoccerAzteca.com

Advertisement

{config_load}

{config_load}用于从配置文件中 加载配置变量#variables#

属性:

参数名称 类型 必选参数 默认值 说明
file string Yes n/a 载入的配置文件名
section string No n/a 指定载入配置变量的段落
scope string no local 配置变量的作用范围,取值local, parent 或 global. local表示变量只能在当前模板的上下文中使用。 parent表示变量可以在当前模板和父模板使用。 global表示变量在任何地方都可用。

Example 7.24. {config_load}

example.conf 配置文件.


#this is config file comment

# global variables
pageTitle = "Main Menu"
bodyBgColor = #000000
tableBgColor = #000000
rowBgColor = #00ff00

#customer variables section
[Customer]
pageTitle = "Customer Info"

  

模板是:


{config_load file="example.conf"}
{config_load "example.conf"}  {* short-hand *}

<html>
<title>{#pageTitle#|default:"No title"}</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>

  

配置文件 可能会有一些段落。你可以用section属性单独载入某个指定段落的配置变量。 注意全局的配置变量会同时被载入,同名的段落配置变量会覆盖全局的配置变量。

Note

配置文件的sections和内置函数{section}是不相关的,它们只是刚好名称比较像。

Example 7.25.  {config_load} 载入段落配置变量


{config_load file='example.conf' section='Customer'}
{config_load 'example.conf' 'Customer'} {* short-hand *}

<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>

  

参见$config_overwrite

参见配置文件, 配置变量, $config_dir, getConfigVars()configLoad().

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 5 plus 16? (Are you human?)

Advertisement