4

What I'm trying to achieve is the following:
A three-level 'category' tree, with at the end channel_entries. So users can browse between categories & access the entries related to that category.

  • Category A
    • Category A.1
      • Entries
    • Category A.2
      • Entries
  • Category B
    • Category B.1
      • Category B.1.1
        • Entries
      • Category B.1.2
        • Entries
  • Category C

I'm already using the Child Categories-plugin,
but it seems like you can't access categories in such 'depth':

Hi,
This add-on supports only 2 levels of categories, i.e. you can display parents and children,
but not grandchildren.

I also tried a combination between the native category tag & child categories,
but no success so far...

Or am I better off by writing a custom query?

What's the best way to approach this?

1
  • 1
    Have you tried GWCode Categories? I always use this add-on for category stuff, it's great. If this works out for you, I made an official answer since this is more or less a question/suggestion. gwcode.com/add-ons/gwcode-categories Dec 6, 2012 at 14:09

1 Answer 1

6

I would go with gwcode-categories: it allows you to target categories by depth.

F.ex:

{exp:gwcode_categories channel="example" depth="3"}
    {cat_name}
{/exp:gwcode_categories}

You can find more info in the docs.

Anyway, your code should be something along these lines:

{exp:gwcode_categories channel="example"}
    {cat_name}
    {if depth == 3}
        <ul>
            {exp:channel:entries channel="example" category="{cat_id}"}
                <li>
                    {title}
                </li>
            {/exp:channel:entries}
        </ul>
    {/if}
{exp:gwcode_categories channel="example"}
1
  • 1
    But remember that the depth-attribute in gwcode-categories always addresses an ABSOLUTE depth, i.e. depth 1 is always root-level.
    – BNetz
    Apr 18, 2014 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.