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 show_empty not working correctly.

January 06, 2012 12:54pm

Subscribe [3]
  • #1 / Jan 06, 2012 12:54pm

    ROCKET MEDIA

    153 posts

    Using this tag:

    {exp:channel:categories channel="event"}
    {category_name}
    {/exp:channel:categories}

    I see the following output:

    • General Test
    • General Test 2

    Using this tag:

    {exp:channel:categories channel="event" show_empty="no"}
    {category_name}
    {/exp:channel:categories}

    I see NO output even though there are entries which are assigned to both categories.

    Simply put—the show_empty parameter seems to be breaking the tag.

    The queries appear fine in the debug, and a quick check of the database tables confirms that the entries are indeed connected properly to their categories. Quite the mystery.

    Any ideas?

    I am running v2.3.1 - Build: Date 20111017

  • #2 / Jan 06, 2012 1:14pm

    glenndavisgroup

    436 posts

    Hi Rocket Media,

    I’m running the same EE version as you and I just tested this tag and it works for me? You must not have anything attached to these 2 categories. I would check your entries to see if you have them assigned to something. By default if you don’t have the show_empty parameter set, the tag will display all categories even if they are empty. This is why the first code you posted works but not the second. You can read more about this here:

    http://ellislab.com/expressionengine/user-guide/modules/channel/categories.html#show-empty

    I hope that helps.

    Mike

  • #3 / Jan 06, 2012 1:21pm

    ROCKET MEDIA

    153 posts

    Mike,

    I have verified that entries are assigned to these categories, both in the database, and by using the following:

    {exp:channel:entries channel="event"}
    {categories}{category_name}
    {/categories}
    {/exp:channel:entries}

    Which outputs successfully:

    General Test
    General Test 2

  • #4 / Jan 08, 2012 9:31am

    Sean C. Smith

    3818 posts

    Hi Rocket media,

    Sorry that you are having this difficulty. I have just tested this in my sandbox installation and have not been able to duplicate your problem. I do want to solve this for you though so let’s keep working on it.

    Could you go through your entries and remove all of one of the categories so that. By this I mean make sure that you have no entries with the category “general test 2” but have some with category “general test” and then try the code again.

    Mike, thanks for the help so far.

    Sean

  • #5 / Jan 20, 2012 11:35am

    ROCKET MEDIA

    153 posts

    Hi Sean,

    I have done as you requested. Using the following code:

    {exp:channel:entries channel="event"}
    {categories}{category_name}
    {/categories}
    {/exp:channel:entries}

    outputs as expected:

    General Test

    I think I may have the answer, is the show_empty not showing the categories because they are only assigned to future entries?

  • #6 / Jan 20, 2012 7:33pm

    Sean C. Smith

    3818 posts

    Rocket,

    That would be correct. If you want to show future entries then add the show_future_entries= parameter and you should be good to go.

    Sean

  • #7 / Jan 23, 2012 9:21am

    ROCKET MEDIA

    153 posts

    show_future_entries=“yes” is a parameter for the exp:channel:entries tag but it is not a parameter for exp:channel:categories Adding it to the categories tag does not work.

    Unfortunately I don’t believe there is (or don’t know of) a way to output a list of categories (without repeats) using the channel:entries tag.

  • #8 / Jan 29, 2012 9:57am

    Sean C. Smith

    3818 posts

    Hi Rocket Media,

    I have searched Devot://ee for category related entries and there are several to look at. I believe this one called, categories will be able to help you out. If not, then look through the others there and hopefully you’ll be able to find what you want.

    Alternatively you could use the Query module to directly query the database to get the information you are looking for.

    Sean

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

ExpressionEngine News!

#eecms, #events, #releases