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.

What I'm doing wrong?

April 04, 2013 5:55pm

Subscribe [3]
  • #1 / Apr 04, 2013 5:55pm

    jolupa

    6 posts

    Hi.

    I want different styles depending on the category of the entries and I’m using the following code:

    {exp:channel:entries channel='blog' limit='10' order_by='date' sort='desc'}
       {if '{category}' == '1' OR category == '2'}
        <div class="twelve columns">
         /themes/site_themes/lgnv1/timthumb/timthumb.php?src={imagen_destacada}&h=150&w=1000&zc=1
         <h1><a href="http://{url_title_path=lgnv1/post}">{title}</a></h1>
         {entrada}
        </div>
       {if:else '{category}' == '3'}
        <div class="twelve columns">
         <h1 class="centered">{title}</h1>
         <center>{entrada}</center>
        </div>
       {/if}
      {/exp:channel:entries}

    But all that I have is an error rendering the page. Also I try with the following code too:

    {exp:channel:entries channel='blog' limit='10' order_by='date' sort='desc'}
       {if category == '1' OR category == '2'}
        <div class="twelve columns">
         /themes/site_themes/lgnv1/timthumb/timthumb.php?src={imagen_destacada}&h=150&w=1000&zc=1
         <h1><a href="http://{url_title_path=lgnv1/post}">{title}</a></h1>
         {entrada}
        </div>
       {if:else category == '3'}
        <div class="twelve columns">
         <h1 class="centered">{title}</h1>
         <center>{entrada}</center>
        </div>
       {/if}
      {/exp:channel:entries}

    Someone can guide me, please.

    Thanks a lot.

  • #2 / Apr 05, 2013 2:27am

    Riverboy

    2993 posts

    Hi, not sure but you use if:else instead of if:elseif, might that be the problem?

    See documents about using those here.

  • #3 / Apr 07, 2013 8:56am

    jolupa

    6 posts

    Well I try the solution you give me but is not working…

    I think I can’t use the category to change the style I want to use, I don’t know.

    Anyone has an idea?

  • #4 / Apr 08, 2013 10:43am

    travisb

    172 posts

    Did you try breaking it down to see if it works in simpler form, for example:

    {exp:channel:entries channel='blog'}
       {if category == "1" OR category == "2"}
        Cat 1 or Cat 2 success
       {/if}
       {if category == '3'}
         Cat 3 success
       {/if}
    {/exp:channel:entries}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases