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.

Displaying Subcategories

September 07, 2008 11:02am

Subscribe [2]
  • #1 / Sep 07, 2008 11:02am

    fearless_shultz

    7 posts

    I have a structure wherby I have a weblog for each of the main areas of the site and have categories for each, some of the categories with sub categories.

    For each of the main categories I have a template group and index template which shows the top level categories and uses parent_only=“yes” to not show sub categories, I also have a sub page template to show the content for each of the categories, my question is, how (assuming it is possible) on the subpages do I show only the child categories for selected parent category?

    Example code for a top level content page menu

    {exp:weblog:categories weblog="toplevel" style="nested" parent_only="yes"}
    
    <a href="http://{path=toplevelmenu/}">{category_name}</a>
    
    {/exp:weblog:categories}

    Also, is it possible to style the menus so that when you are on a subpage and the child categories are showing under the main one, the child categories are indented?

    Many thanks for any help! 😊

  • #2 / Sep 08, 2008 9:08am

    Boyink!

    5011 posts

    For displaying subcategories only you’ll need to go beyond default EE.  This 3rd party plugin might do the trick.

    For indenting - are you returning the list as a nested unordered list?  If so you can do the indenting with CSS.

  • #3 / Sep 09, 2008 7:15am

    fearless_shultz

    7 posts

    Hi Michael,

    Many thanks for the reply, it does look like that plugin is what I need to achieve what I am after. I have a couple of issues but will post those over at the other thread.

    I do have what I think is a more general question relating to categories though that I wonder if anyone can help with.


    * Found the solution to this problem in Weblog Global preferences 😊 Just the plugin that I am having issues with now!

    Auto-Assign Category Parents
    If set to “yes”, when new entries are submitted, the parent category will be automatically assigned whenever you choose a child category

    When posting into a sub category it also seems to be posting into the parent category and vice versa. Is this something that I also need to do with the above plugin or does expression engine have the native ability to do this?

    My code for displaying the content for in the subpages is quite simple as follows:

    {exp:weblog:entries weblog="busdev" limit="15"}
    {name}
    {address}
    {/exp:weblog:entries}

    This displays the content for a parent category with no problems but as mentioned it also displays content that has been posted in a child category underneath it.

    Any help would be hugely appreciated as it is driving me nuts!


    * Edit *

    I don’t seem to be able to post in the plugin thread for some reason so will ask here incase anyone can help.

    The problem I have having is that when clicking on Any menu option, I get all of the sub categories for all of the menu options even when clicking on a menu option that doesn’t itself have any sub categories associated with it. Any thoughts on this? my code for the menu is below

    {exp:weblog:categories category_group="5"  weblog="busdev"}
    {exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="3" site="1"}
    
    <h1>{category_id}</h1>
    
      {child_category_start}
    
    <a href="http://{path=BusinessDevelopment/BusinessDevelopmentSub/}">{child_category_name}</a>
      {child_category_end}
    
    
      {/exp:child_categories} 
    {/exp:weblog:categories}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases