IF statement in Smarty

Discussion in 'Programming' started by Nima, Mar 30, 2013.

  1. #1
    I want to have an IF statement that checks whether the scriptname ends with '-dictionary'. I'm not sure how to do the first variable part. This is my attempt so far but not working

    {if $scriptname == "*.-dictionary"}
     
    Nima, Mar 30, 2013 IP
  2. trecords

    trecords Well-Known Member

    Messages:
    145
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #2
    Hi, There are substr function for smart which could be quite helpful:
    {if {$scriptname|truncate:-11} == "-dictionary"}
    Code (markup):
     
    trecords, Mar 31, 2013 IP
    Nima likes this.
  3. Nima

    Nima Well-Known Member

    Messages:
    3,489
    Likes Received:
    243
    Best Answers:
    0
    Trophy Points:
    175
    #3
    Thanks. Thanks to Bruce from phpLD, I ended up using the substr function.

    {if $scriptname|strstr:"-dictionary"}
     
    Nima, Mar 31, 2013 IP