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.

Some sort of category variable

July 11, 2011 2:28pm

Subscribe [2]
  • #1 / Jul 11, 2011 2:28pm

    TJ Draper

    222 posts

    What I’m looking for is a way to display the word “Category” if a particular channel entry is only assigned one category, but display the word “Categories” if the channel entry has more than one category assigned to it. Currently my category footer on channel entries looks like this:

    <strong>Category:</strong> {categories backspace="8"}<a href="http://{path={segment_1}/index}">{category_name}</a> • {/categories}

    So if I can change that word “Category” based on whether there is more than one category that would be awesome.

    Anyone have anything?

    Thanks!

  • #2 / Jul 12, 2011 9:29am

    the3mus1can

    426 posts

    You could use the query module.

    {exp:query sql="SELECT COUNT(cat_id) as cat_count FROM exp_category_posts WHERE entry_id = {entry_id}"}
    
        {if cat_count == 1}
            Category:
        {if:else}
            Categories:
        {/if}
    
    {/exp:query}

    Warning: Untested SQL!

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

ExpressionEngine News!

#eecms, #events, #releases