ECSHOP模版系統(tǒng)Assign和Include模版標(biāo)簽介紹,assign 用于在模板被執(zhí)行時為模板變量賦值,Include 標(biāo)簽用于在當(dāng)前模板中包含其它模板. 當(dāng)前模板中的變量在被包含的模板中可用。 必須指定 file 屬性,該屬性指明模板資源的位置。如果設(shè)置了 assign 屬性,該屬性對應(yīng)的變量名用于保存待包含模板的輸出,這樣待包含模板的輸出就不會直接顯示了。
| 屬性 | 類型 | 是否必須 | 缺省值 | 描述 |
| var | string | Yes | N/A | 被賦值的變量名 |
| value | string | Yes | N/A | 賦給變量的值 |
描述:
assign 用于在模板被執(zhí)行時為模板變量賦值.
例子:
{assign var="name" value="Bob"}輸出:
The value of $name is Bob.
| 屬性 | 類型 | 是否必須 | 缺省值 | 描述 |
| file | string | Yes | N/A | 待包含的模板文件名 |
| assign | string | Yes | N/A | 該屬性指定一個變量保存待包含模板的輸出 |
| [var …] | [var type] | Yes | N/A | 傳遞給待包含模板的本地參數(shù),只在待包含模板中有效 |
描述:
Include 標(biāo)簽用于在當(dāng)前模板中包含其它模板. 當(dāng)前模板中的變量在被包含的模板中可用。必須指定 file 屬性,該屬性指明模板資源的位置。
如果設(shè)置了 assign 屬性,該屬性對應(yīng)的變量名用于保存待包含模板的輸出,這樣待包含模板的輸出就不會直接顯示了。
例子1:
{include file="header.tpl"}{* body of template goes here *}{include file="footer.tpl"}可以在屬性中傳遞參數(shù)給待包含模板. 傳遞給待包含模板的參數(shù)只在待包含模板中可見. 如果傳遞的參數(shù)在待包含模板中有同名變量,那么該變量被傳遞的參數(shù)替代。
例子2:
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}{* body of template goes here *}{include file="footer.tpl" logo="http://my.domain.com/logo.gif"}包含 $template_dir 文件夾之外的模板請使用 模板資源 說明的格式.
例子3:
{* absolute filepath *}{include file="/usr/local/include/templates/header.tpl"}{* absolute filepath (same thing) *}{include file="file:/usr/local/include/templates/header.tpl"}{* windows absolute filepath (MUST use "file:" prefix) *}{include file="file:C:/www/pub/templates/header.tpl"}{* include from template resource named "db" *}{include file="db:header.tpl"}
新聞熱點
疑難解答