开发者

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}


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 ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜