Lucas
Lucas

Reputation: 2994

smarty - how to use variables in code?

This is part of my smarty code:

{if $cat=="3_0" or $cat=="3_15" or $cat=="3_16" or $cat=="3_17"}

How can I setup my code to use variable for characters (numbers) 15, 16, 17...? For example I would like have short code like that:

{if $cat=="3_0" or $cat=="3_"+ any two characters}

Upvotes: 0

Views: 214

Answers (1)

John Smith
John Smith

Reputation: 808

I think that you can do something like:

{if $cat|substr:0:2 eq "3_"}

or

{if $cat|truncate:2 eq "3_"}

http://www.smarty.net/docsv2/en/language.modifiers.tpl

Let me know ;)

Upvotes: 1

Related Questions