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.

Categories tag not parse if conditional is in pair variable after updating 2.1.3 -> 2.3.1

January 09, 2012 2:38pm

Subscribe [3]
  • #1 / Jan 09, 2012 2:38pm

    Categories tag not parse when conditional is in the variable pair after upgrading to EE 2.3.1 (previously 2.1.3)

    Its happen in only one of my multisite install

    This code not work :

    {categories}
    {if category_id == "12" OR category_id == "18" OR category_id == "25"}
    {if channel_id == "2"}
    <a href="http://{path=summum/liste_fille}">{category_name}</a>
    {if:else}
    <a href="http://{path=summum/liste_chronique}">{category_name}</a>
    {/if}
    {if:else}
    {if channel_id == "2"}
    <span class="couleur"><a href="http://{path=summum/liste_fille}">{category_name}</a></span>
    {if:else}
    <span class="couleur"><a href="http://{path=summum/liste_chronique}">{category_name}</a></span>
    {/if}
    {/if}
    {/categories}

    output :
    {categories} {category_name} {/categories}

    this code work :

    {categories}
    {category_name}
    {/categories}

    But all work fine in my second site using MSM

    Sorry for the bad english, im a french canadian…

  • #2 / Jan 10, 2012 4:42pm

    Dan Decker

    7338 posts

    Hi Alexandre Laplante,

    No worries on the English! I can’t say why these conditionals stopped working after your upgrade, but I may have a solution that will work a bit more efficienly:

    {categories show="12|18|25"}
     {if channel_id == "2"}
     <a href="http://{path=summum/liste_fille}">{category_name}</a>
     {if:else}
     <a href="http://{path=summum/liste_chronique}">{category_name}</a>
     {/if}
    {/categories}
    {categories show="not 12|18|25"}
     {if channel_id == "2"}
     <span class="couleur"><a href="http://{path=summum/liste_fille}">{category_name}</a></span>
     {if:else}
     <span class="couleur"><a href="http://{path=summum/liste_chronique}">{category_name}</a></span>
     {/if}
    {/categories}

    This first loop will only show the categories listed in the the show= parameter and then execute the conditional inside the loop. The second loop will exclude the categories from the list using the “not” operator and then execute the conditional. This should ultimately speed up your template and simplify the execution of your conditionals.

    Let me know if that works for you.

    Cheers!

     

  • #3 / Jun 18, 2012 3:12pm

    amityweb

    162 posts

    Just wanted to say this happened to me too. I already raised a new thread so here’s the link for anyone else finding this post http://ellislab.com/forums/viewthread/219441/ But the solution above wont work for me I dont think. I need the conditional to check if the category_name exists or not (I do something different IF an entry has a category_name compared to if not).

  • #4 / Jun 18, 2012 3:25pm

    amityweb

    162 posts

    Found a solution on my post above… you probably fixed it by now! But my solution was wrapping category_id in quotes and brackets, e.g.:

    {if {"category_id"} == "25"}
  • #5 / Jul 26, 2012 11:56am

    alvarilio

    18 posts

    Same issue, but the soltions above didnt work.

    {categories}
                {if {total_results }}
                   {if category_id !='11' && category_id !='12'}
                      <a href="http://{path=portfolio/}">{category_name}</a>
                   {/if}
                {/if}
             {/categories}


    When I take out the if category_id != etc, then it works.

    If I wrap category_id in {""} like Amity suggested I get the following error:

    Parse error: syntax error, unexpected '{' in /home/.../expressionengine/libraries/Functions.php(680) : eval()'d code on line 112

    But if I leave out the quotes, it works.

    {categories}
                {if {total_results }}
                   {if {category_id} !='11' && {category_id} !='12'}
                      <a href="http://{path=portfolio/}">{category_name}</a>
                   {/if}
                {/if}
             {/categories}

     

     

  • #6 / Jul 27, 2012 3:28pm

    Dan Decker

    7338 posts

    Hi alvarilio,

    Thanks for providing your solution!

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases