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.

Category ID Not Evaluating or Displaying

February 27, 2014 5:57pm

Subscribe [2]
  • #1 / Feb 27, 2014 5:57pm

    dallasthiele

    6 posts

    Just found out category_id isn’t functioning sitewide. Since it’s barely used I didn’t realize it wasn’t working and I’m not sure when it stopped.

    I use it in one of my templates with the following:

    {exp:channel:entries channel="blog" limit="1" status="open" site="naperville"}
    <h2>Recent Blog</h2>
    <h3>{if category_id == '28'}<a href="/mystory">{if:else}<a href="/resources/blogs/#reflections" class="{category_id}">{/if}{title}</a></h3>
    <p>{blog_description}<br />
    by {blog_author}<br />
    {exp:word_limit total="30"}<br />
    {blog_content}<br />
    {/exp:word_limit}<br />
    {if category_id == '28'}<a href="/mystory">Read more</a>{if:else}<br />
    <a href="/resources/blogs/">Read more</a>{/if}<br />
    {/exp:channel:entries}

    The template is returning {category_id} as the class and every blog is returning the else if my conditionals.

    Any idea what could be causing this?

  • #2 / Mar 07, 2014 7:14am

    ahmad saad

    364 posts

    Hi,

    {category_id} is not a {channel:entries} variable , u must put it in {categories}{/categories}loop like this:

    exp:channel:entries channel="blog" limit="1" status="open" site="naperville"}
    <h2>Recent Blog</h2>
    <h3>{categories}{if category_id == '28'}<a href="/mystory">{if:else}<a href="/resources/blogs/#reflections" class="{category_id}">{/if}{title}</a>{/categories}</h3>
    <p>{blog_description}<br />
    by {blog_author}<br />
    {exp:word_limit total="30"}<br />
    {blog_content}<br />
    {/exp:word_limit}<br />
    {categories}{if category_id == '28'}<a href="/mystory">Read more</a>{if:else}<br />
    <a href="/resources/blogs/">Read more</a>{/if}{/categories}<br />
    {/exp:channel:entries}

    check http://ellislab.com/expressionengine/user-guide/add-ons/channel/channel_entries.html#id145  for more info

  • #3 / Mar 09, 2014 2:14pm

    dallasthiele

    6 posts

    Thank you Ahmad! Did not realize it was a tag pair. So obvious now that I look back at the documentation.

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

ExpressionEngine News!

#eecms, #events, #releases