开发者

smarty - how to use variables in code?

开发者 https://www.devze.com 2023-04-06 13:39 出处:网络
This is part of my smarty code: {if $cat==\"3_0\" or $cat==\"3_15\" or $cat==\"3_16\" or $cat==\"3_17\"}

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

精彩评论

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

关注公众号