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 in online catalog

September 02, 2010 2:33am

Subscribe [2]
  • #1 / Sep 02, 2010 2:33am

    Greg Griffith

    37 posts

    I don’t know what it is that makes me glaze over whenever I need to do something beyond the basics concerning categories, but here it is:

    I have a product catalog with a category structure like this:

    Hats

    - Hard Hats
    - - Yellow Hats
    - - - yellow hat #1
    - - - yellow hat #2
    - - - yellow hat #3
    - - Green Hats
    - - - green hat #1
    - - - green hat #2
    - - Red Hats
    - - - red hat #1
    - - - red hat #2
    - - - red hat #3
    - - - red hat #4

    - Soft Hats
    - - Beige Hats
    - - - beige hat #1
    - - Tan Hats
    - - - tan hat #1
    - - - tan hat #2
    - - - tan hat #3
    - - Mauve Hats
    - - - mauve hat #1


    Gloves

    - Work Gloves
    - - work glove #1
    - - work glove #2
    - Driving Gloves
    - - driving glove #1
    - - driving glove #2
    - - driving glove #3
    - - driving glove #4

    In other words: Some top-level categories have children. Some have children and grandchildren. Some have children and grandchildren and great-grandchildren.

    There is no set number of levels between top-level category and individual item - sometimes it’s 1, sometimes it’s 2, sometimes it’s even 3.

    What I want to do is create a template that shows all top-level categories.

    I want to link all those categories to the same template, and pass that template a category ID, so that no matter how many levels deep I’m going, the same template will continue to show just the next level of categories down from the one the user clicked.

    I’m unable to do it using this code:

    {exp:weblog:categories weblog="accessories" parent_only="yes"}s
    
        <a href="http://{path=products/accessories/}">_        {category_image}_        {category_name}_        {category_description}_    </a>
    
    {/exp:weblog:categories}

    So that’s problem number one.

    The second problem is: I need to know when I’m at the end of a branch, so I’ll know when to iterate through entries in the last category, instead of iterating through the children of the current category.

    I see a lot of examples here in the forums and around the web that use product catalogs, and so far I haven’t seen anything describing exactly what I’m trying to do… but I can’t imagine nobody’s had a need to do this before. Maybe I’m just glazing over again.

    Shouldn’t both of these things - the recursive category display, and the end-of-branch check - be possible without plugins - with just EE’s native tags?

    Thanks in advance to anyone who takes the time to read this and offer a response.

  • #2 / Sep 02, 2010 1:57pm

    Brandon Jones

    5500 posts

    Hi Greg,

    We may need to shift this over to the CodeShare Corner since categories are working as designed, however:

    Regarding your first issue, I’m not seeing category_id being appended in that link; if it were you could try grabbing the id from the proper segment and using that to feed the show parameter.

    Depending on exactly what your expected output is you will definitely want to look at the Child Categories plugin for your second issue (and possibly also your first). There are of course custom queries that would work as well, though we can’t specifically support those.

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

ExpressionEngine News!

#eecms, #events, #releases