[英]Smarty templates take variable and use in include string?
我正在使用一個使用智能模板的購物車(CS-cart)。 產品與品牌相關聯。 當產品頁面呈現時,我能夠獲得品牌ID。
我也有自定義的.tpl文件,例如brand1.tpl brand2.tpl,其中數字表示db表中的行id。
如果我在變量中有品牌ID,有人會向我展示如何包含自定義模板並動態使用品牌ID變量代替包含的文件名中的數字。 像下面的東西,但我認為$ bid是插入變量的一種方式。 任何幫助表示贊賞
謝謝
{include file ='brand $ bid.tpl'}
嘗試使用雙引號示例
{* body of template goes here, the $tpl_name variable
is replaced with a value eg 'contact.tpl'
*}
{include file="$tpl_name.tpl"}
查看文檔: http : //www.smarty.net/docs/en/language.syntax.quotes.tpl示例3.6涵蓋了您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.