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.

Using category id with a conditional

May 15, 2011 2:12pm

Subscribe [5]
  • #1 / May 15, 2011 2:12pm

    James Hurst

    48 posts

    Does anyone know if its possible to use a category ID inside an {if} conditional.

    Ideally I would like to say something along the lines of:

    {if category_id == "1"}
    content
    {/if}

    Let me know your thoughts -
    Many thanks -
    James

  • #2 / May 16, 2011 6:20am

    John Henry Donovan

    12339 posts

    James,

    It sure is. Make sure it is wrapped in the {categories} tag pair first though if using inside the {exp:channel:entries} tag

    {exp:channel:entries channel="blog" limit="10"}
    
      {categories} 
        {if category_id == "1"}
         content
        {/if}
      {/categories}
    
    {/exp:channel:entries}

    Does that help?

  • #3 / May 20, 2011 5:34pm

    focusfusion

    58 posts

    Brilliant!  That worked for me too.  Thanks so much!  And great forums, I found the answer quickly.

  • #4 / May 21, 2011 1:59pm

    Greg Salt

    3988 posts

    Hi Cure Studio,

    Did John Henry’s advice help you out with this?

    Cheers

    Greg

    @focusfusion, glad that you found this useful.

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

ExpressionEngine News!

#eecms, #events, #releases