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.

If statement based on category inside a entries tag?

May 24, 2012 4:54am

Subscribe [1]
  • #1 / May 24, 2012 4:54am

    MrTomTom

    30 posts

    Hi there,

    I am hoping this is very simple to do, it’s just I’ve never done it before!

    Basically I just want to display a specific background image for entries if they belong to a specific category.

    Is something like this the best way to achieve it? (where category 3 is the one I am checking for

    {categories show="3"}
        {if " {category_id}" =="3"}
           <div>some content…</div> 
       {/if}  
    {/categories}


    Any Suggestions?

    Thanks,

    Tom

  • #2 / May 25, 2012 10:46am

    Dan Decker

    7338 posts

    Hi Tom,

    Thanks for your question!

    You should think about using the Category Image feature. Add your image to the category and then you can call it like so:

    {categories}
       <div s tyle="background: url('{category_image}')">
        ... content ...
       </div>
    {/categories}

    Cheers,

     

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

ExpressionEngine News!

#eecms, #events, #releases