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.

Categories Are Driving Me Nuts! Help!

March 22, 2011 1:51pm

Subscribe [3]
  • #1 / Mar 22, 2011 1:51pm

    Design ID

    9 posts

    Hi Guys,

    I’m have real trouble getting Categories to behave for me.

    I have a Category Group with about 30 categories in it. There are 5 Parent Categories each with several Child Categories. One of the Child Categories has Child Categories of it’s own. In other words there are 3 levels to the hierarchy. (Parent > Child > Grandchild).

    The following code works fine and shows all categories except those listed (14,27,28,7) and their children.

    {exp:channel:categories category_group="3" channel="my-channel-name" show="not 14|27|28|7" style="linear" show_empty="yes"}
    
    <h2><a href="http://{category_url_title}">{category_name}</a></h2>
    
    <p>{/exp:channel:categories}

    The title of Category 20 shows up in the list as expected, as it is not excluded by the ‘Show’ option.

    However, if I change the ‘Show’ option to ONLY show Category 20 (as below) - I get nothing!

    {exp:channel:categories category_group="3" channel="my-channel-name" show="20" style="linear" show_empty="yes"}
    
    <h2><a href="http://{category_url_title}">{category_name}</a></h2>
    
    <p>{/exp:channel:categories}

    Category 20 DOES show up if I Show its Parent Category as well (Which I don’t want to do). i.e. show=“18|20”

    Could it be because I turned “Auto-Assign Category Parents” OFF?

    I had to do that because when I try to show Entries belonging to a Child Category, Parent Entries were showing up as well - which is just nuts!

    I’ve spent a day trying to work this out - no joy!

    Please help.

  • #2 / Mar 23, 2011 7:47am

    John Henry Donovan

    12339 posts

    Design ID,

    Category 20 DOES show up if I Show its Parent Category as well (Which I don’t want to do). i.e. show=“18|20”

    This is intended. From the docs

    Note: If you specify that a parent category is not shown, then any children of that parent category are then unable to be shown by the tag. The parent category is required for any and all children categories.

    You are welcome to make a feature request but in the meantime take a look at the category add-ons available as I am sure one will suit your purpose

  • #3 / Mar 23, 2011 8:41am

    Design ID

    9 posts

    Hi John,

    I eventually got things to work by using Low’s Seg2Cat plug-in that let me pull the category ID from the URL. I was then able to show only categories whose parent ID matched it.

    {exp:channel:categories category_group="3" channel="{segment_1}" style="linear" show_empty="yes"}
    
        {if parent_id == segment_3_category_id }
    
            <h2><a href="http://{category_url_title}">{category_name}</a></h2>
    
    <p>    {/if}</p>
    
    <p>{/exp:channel:categories}

    There needs to be a lot more flexibility around how categories can be specified, and clearer examples of some less straight-forward uses of them in the user guide. The learning curve is very steep and I already have several plug-ins installed to handle tasks you would assume would be straight-forward, but that EE does not do out of the box.

  • #4 / Mar 23, 2011 4:43pm

    Sue Crocker

    26054 posts

    Hi, Design ID:

    Which particular plugins are you using that you believe would be helpful to have their functionality built in?

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

ExpressionEngine News!

#eecms, #events, #releases