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.

How many elseif allowed?

January 04, 2008 2:51am

Subscribe [4]
  • #1 / Jan 04, 2008 2:51am

    alex7

    130 posts

    Is it semantically correct to use this kind of code?

    {if condition-1=="some value"}
       content
    {if:elseif condition-2=="another value"}
       another content
    {if:elseif condition-3=="more value"}
       more content
    {if:elseif condition-4=="yet more value"}
       yet more content
    {if:else}
       other content
    {/if}
  • #2 / Jan 04, 2008 2:47pm

    alex7

    130 posts

    I wonder – is this too simple question or too difficult one?  Nobody has a clue? :sick:

  • #3 / Jan 04, 2008 2:53pm

    Lisa Wess

    20502 posts

    You want to be explicit in your conditionals, so you want the == and the comparision, but otherwise correct.  For instance, from:

    {if condition-1}

    to

    {if condition-1 == "value"}
  • #4 / Jan 04, 2008 3:05pm

    alex7

    130 posts

    Thank you Lisa! Edited. So I can use unlimited number of nested “elseif” in block?

  • #5 / Jan 04, 2008 3:08pm

    Lisa Wess

    20502 posts

    Yep, that shouldn’t be a problem; I have a conditional that’s somewhat more complicated right on my index template. 😉

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

ExpressionEngine News!

#eecms, #events, #releases