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_name} remove parent category from output

May 25, 2010 6:37pm

Subscribe [3]
  • #1 / May 25, 2010 6:37pm

    Darrell Wilson

    23 posts

    Hi,

    I’m pretty experienced with EE but I haven’t used the categories tag too often.

    I’ve got a category group with three parent categories each of which has approx. 5 subcategories. The page has a drop-down ‘jump menu’ which reloads the same template and dynamically pulls out entries from the selected subcategory.

    All is working fine except the {category_name} tag which displays both the parent category as well as the subcategory. I only want it to display the subcategory title for use as a header (the parent categories don’t have any entries - they are just titles)

    The code I’m using to display the title of the selected subcategory is:

    {exp:weblog:entries weblog="resources" dynamic="on" limit="1"}
    <h3>{categories}{category_name}{/categories}</h3>
    <p>{/exp:weblog:entries}

    The {category_name} tag generates this:

    Teams & StaffConferences, Meetings & Events

    ‘Teams & Staff’ is the title of the parent category and ‘Conferences, Meetings & Events’ is the title of the subcategory currently being viewed. What I want is for the {category_name} tag to simply output the subcategory title - ‘Conferences, Meetings & Events’

    The test page can be viewed at

    http://www.glasgowservicewithstyle.com/index.php/teams-staff/support-new/

    The ‘jump menu’ is in the right column.

    Any advice appreciated,

    Darrell

  • #2 / May 25, 2010 8:42pm

    Brandon Jones

    5500 posts

    Hi Darrell,

    I’m going to move this over to How-to as this is the intended behavior. You might consider the following thread, and hopefully you’ll get some more info in this forum.

    http://ellislab.com/forums/viewthread/52259/

  • #3 / May 26, 2010 2:18am

    Wouter Vervloet

    758 posts

    Hi Darrel,

    Since you’re never gonna use the parent categories, wouldn’t it be easier to create 2 category groups? One called Teams & Staff and other called ‘Lorem ipsum’. You can easily add your 5 subcategories to those groups and be done with it as I don’t think there is a way to hide the parent category in the {categories} tag.

    Greetz,
    Wouter

  • #4 / May 26, 2010 8:35am

    Darrell Wilson

    23 posts

    Brandon, Wouter,

    Thanks for the advice. I split the categories into multiple groups and it works fine now.

    Darrell

  • #5 / May 26, 2010 8:54am

    Wouter Vervloet

    758 posts

    Always glad to help.

    Greetz,
    Wouter

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

ExpressionEngine News!

#eecms, #events, #releases