Smarty templates accept a variable and use in include string?

I work with a shopping cart (CS-cart) that uses smarty templates. Products associated with the brand. When the product page displays, I can get the brand ID.

I also have custom .tpl files like brand1.tpl brand2.tpl where the number represents the row id from the db table.

If I have a brand identifier in a variable, someone will show me an example of how to enable a custom template and dynamically use a brand identifier variable instead of the number in the specified file name. Something like below, but I don't think $ bid is a way to insert a variable. Any help is appreciated

thanks

{include file = 'brand $ bid.tpl'}

+4
source share
2 answers

try using double quotes Example

{* body of template goes here, the $tpl_name variable is replaced with a value eg 'contact.tpl' *} {include file="$tpl_name.tpl"} 
+5
source

See the documentation: http://www.smarty.net/docs/en/language.syntax.quotes.tpl Example 3.6 covers your question.

+4
source

Source: https://habr.com/ru/post/1393061/


All Articles