Skip to content
Advertisement

use multiple files in category.tpl with smarty

{$category->id|escape:'htmlall':'UTF-8'} this smarty code is for get id number on category.tpl

we have lot of category id’s example 2,6,8,10 etc etc and in my folder lots of files names example 2minimum.txt, 6minimum.txt, 8minimum.txt, 10minimum.txt etc etc

i want to use include file when current category id page with category id number txt file.

{include file='folder/2minimum.txt'} <=- this will work perfect when i put file name but i want to use like this

{include file='folder/{$category->id|escape:'htmlall':'UTF-8'}minimum.txt'}

but it’s give error

experts need you help to solve this

Advertisement

Answer

You should use smarty cat to concatenate variable to your file name. In your example it should look something like:

{include file='folder/'|cat:{$category->id|escape:'htmlall':'UTF-8'}|cat:'minimum.txt'}

Link to smarty documentation

Hope it helps, have a nice day!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement