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.

Child categories

August 02, 2007 12:30pm

Subscribe [2]
  • #1 / Aug 02, 2007 12:30pm

    Moonfish

    7 posts

    Think this has been posted before but can’t find a solid answer. All I need to do is display the child categories of a parent category.

    I was trying category= (below) but that’s obviously the wrong approach.

    <ul>
    {exp:weblog:categories weblog="default_site" category="29" show_empty="yes" style="linear"}
    <li><a href="#" title="View entries">{category_name}</a></li>
    {/exp:weblog:categories}
    </ul>

    Want to avoid extensions/plugins if possible. Any help much appreciated.

  • #2 / Aug 02, 2007 12:53pm

    Robin Sowell

    13255 posts

    You could pipe all of the categories you want to show in the category=”” parameter- so if you want to show cats 5,6,7 it would be category=“5|6|7” - but there isn’t a parameter in that tag to show the children of ‘x’- to do that, you’d need a query or a third party plugin.  Make sense?

  • #3 / Aug 02, 2007 1:04pm

    Moonfish

    7 posts

    Yeah that makes sense. It just means if my client adds/removes a category in future, I’ll have to update the template to add/remove the category id. No major sweat though.

    Thanks.

  • #4 / Aug 02, 2007 1:20pm

    Moonfish

    7 posts

    Actually, I’ve just tried that and my template is still displaying all categories. Here’s my code…

    <ul>
    {exp:weblog:categories weblog="default_site" category="39|52|27|38|53|54|43" show_empty="yes" style="linear"}
    <li><a href="#" title="View entries">{category_name}</a></li>
    {/exp:weblog:categories}
    </ul>

    What am I doing wrong?

  • #5 / Aug 02, 2007 1:24pm

    Robin Sowell

    13255 posts

    I would have sworn category was a valid parameter- but it’s just category group.  Sorry for leading you astray there.  OK- 3 options- a query, the subcategory 3rd party plugin, just hard code the links.  If you are specifying the category in a parameter anyway?  I’d just hard code the links.  It’s leaner and it’s non-dynamic anyway.  If you need it to be dynamic?  Then I’m thinking query or the subcategory plugin.

    Make sense?

  • #6 / Aug 02, 2007 1:29pm

    Moonfish

    7 posts

    Yes, thanks. I’ll just hard-code them in. What’s the best syntax to link to pass the subcategory id on to a subcategory template? I want to automagically display only subcategory entries on the destination page.

    Thx

  • #7 / Aug 02, 2007 6:11pm

    Ryan Irelan

    444 posts

    Doing a custom query to get this info isn’t very difficult and I’d bet someone has already posted the code in the forums. However, there is a subcategory plugin. Let me find the link…ah, yes, here it is. I used this sucessfully on a business site I did a couple of months back.

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

ExpressionEngine News!

#eecms, #events, #releases