ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

conditionals not working -- please help

August 24, 2010 3:17pm

Subscribe [3]
  • #1 / Aug 24, 2010 3:17pm

    phoebe_reed

    82 posts

    Hi,
    I’m doing some conditionals on a search results page, and I think either there are limitations I have not found in the docs, or I am doing something wrong.

    Example one:

    What does NOT work:

    {if:elseif weblog_short_name="myname1"}

    This returns a totally blank page, indicating that the syntax has caused an error.
    What *does* work is:

    {if:elseif weblog_short_name=="myname1"}

    My need is to say, if the weblog short name contains a word, then act this way.  I have 14 weblogs that have the word “news” in them, and want to have a rule for all of them without listing them out.

    So, this has not worked.

    My other attempt to solve the problem also doesn’t seem to be working…probably the same limitation:

    {if:elseif weblog_short_name="myname1|myname2|myname3|myname4"}

    Is my syntax incorrect, or is there a limitation that you cannot do “contains” matching with an elseif statment? 

    Thanks
    Phoebe

  • #2 / Aug 24, 2010 3:23pm

    Ingmar

    29245 posts

    Two things: 1) No, you cannot do a “contains” match like that, and 2) the equal comparison operator does indeed contain of two equal signs, {if foo == bar}.

  • #3 / Aug 25, 2010 7:22pm

    phoebe_reed

    82 posts

    thanks.

    right, but if you do usually a search or if statement with ONE equal sign, then usually it means “contains”.

    so {if foo = "bar"}

    translates to

    if foo contains the word bar anywhere in it.

    That works, but not in this kind of conditional, which is odd (to me)

    I found a workaround tho.

    Thanks!

    Phoebe

  • #4 / Aug 26, 2010 6:29am

    Sue Crocker

    26054 posts

    Glad you found a workaround. Don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases