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.

Sub Category inside Parent Category

August 12, 2010 2:08pm

Subscribe [3]
  • #1 / Aug 12, 2010 2:08pm

    MAYO

    53 posts

    What id like to do is, list all top level / parent categories on a menu. Once you click this, it then shows you the sub categories of that parent category on a separate page.

    Ive tried a few hack’s but it just doesn’t seem to work, i also tried this: http://ellislab.com/forums/viewthread/87639/

    But it seems to display the categories, but once you click inside one, it shows ALL entries?! OR it will show child categories that don’t belong in that parent category.

    Is there any help you can give or solutions? Surely theres an easier way than hacks and plugins?

  • #2 / Aug 12, 2010 3:30pm

    Ingmar

    29245 posts

    What version and build of EE are you using? Yes, clicking a category link would show all entries belonging to that category. That is, in fact, expected behavior. Perhaps you can show us in a little more detail what exactly you are trying to accomplish?

  • #3 / Aug 12, 2010 3:57pm

    MAYO

    53 posts

    Currently using 1.6.9.

    What i need to do is in this screenshot:

    http://grab.by/5Sn1

    So when your inside a parent category, it then shows its sub categories, but on a separate page, rather than a drop down menu.

  • #4 / Aug 12, 2010 4:52pm

    Ingmar

    29245 posts

    I am afraid you would need some custom code to achieve just that, perhaps a plugin.

  • #5 / Aug 22, 2010 10:13am

    MAYO

    53 posts

    Yeah, i figured this one out using ‘Child Categories’ plugin and also the ‘Category ID’ plugin:

    In my “Navigation” embed file:

    {exp:child_categories parent="1|2" show_empty="yes"}
        {parent_category_start}
            <h1><a href="http://{homepage}/shop/{parent_category_url_title}/">{parent_category_name}</a></h1>
        {parent_category_end}
    {/exp:child_categories}

    In my “Shop” template folder which outputs the sub categories, and entries, then the entry. I also made it produce a nice URL stack 😊

    {assign_variable:my_weblog="default_site"}
    
    {if segment_3=="" AND segment_4=="" AND segment_5==""}
    
        {exp:category_id category_group="1" category_url_title="{segment_2}" parse="inward"}
            {exp:child_categories parent="{category_id}" parse="inward"}
                {child_category_start}
                    <a href="http://{homepage}/shop/{parent_category_url_title}/{child_category_url_title}/">{child_category_name}</a>
                {child_category_end}
            {/exp:child_categories}
        {/exp:category_id}
        
    {if:elseif segment_3!="" AND segment_4=="" AND segment_5==""}
    
        {exp:category_id category_group="1" category_url_title="{segment_2}" parse="inward"}
            {exp:child_categories parent="{category_id}" show_empty="yes" parse="inward"}
                {entries_start}
                    <a href="http://{homepage}/shop/{parent_category_url_title}/{child_category_url_title}/{url_title}/">{title}</a>
                {entries_end}
            {/exp:child_categories}
        {/exp:category_id}
    
    {if:elseif segment_4!=""}
    
        {exp:weblog:entries weblog="{my_weblog}" limit="1" url_title="{segment_4}"}
            {title}
            {body}
        {/exp:weblog:entries}
    
    {/if}
  • #6 / Aug 22, 2010 11:09am

    Sue Crocker

    26054 posts

    Glad you found a solution. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases