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.

Testing for categories for a channel entry

October 01, 2010 7:52am

Subscribe [3]
  • #1 / Oct 01, 2010 7:52am

    kyan

    11 posts

    Whats the best way to check if a channel entry is assigned to any categories for a given category group.

    I have the following set up in my template:

    <dt>Category:</dt><dd>{categories show_group="5" backspace="2"}{category_name}, {/categories}</dd>

    However, i would like an {if} statement to check the number of categories first. If the count is 0 then i dont want to output this <dt> in my template at all. Im aware of the {total_results} variable but this seems to relate to the entry i am viewing and not the number of categories found.

    Haven’t found anything in the documentation about this so far.

    Thanks.

  • #2 / Oct 01, 2010 5:15pm

    Sue Crocker

    26054 posts

    Have you seen:

    http://devot-ee.com/add-ons/entry-category-count/

    That should help.

  • #3 / Oct 04, 2010 5:28am

    kyan

    11 posts

    Thanks for the suggestion but it doesnt look like this will allow us to specify a category group to check against. It’s also for EE1.0.

  • #4 / Oct 04, 2010 3:45pm

    Ingmar

    29245 posts

    This sounds like a good possible feature request. For the time being I would, perhaps, suggest a custom SQL query.

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

ExpressionEngine News!

#eecms, #events, #releases