1

For a given channel, is it possible to loop through the categories associated with its entries in alphabetical order, then nested-loop through the entries under that category? I'm trying to build a tree-view like template.

2 Answers 2

2

You can use the category_archive tag for this unless I've misunderstood your question: http://ellislab.com/expressionengine/user-guide/modules/channel/category_archive.html

1

Something like this with Stash should do the trick:

{exp:channel:entries channel="news"}
    {categories}
        {exp:stash:append_list name="item_{category_id}"}
            {stash:title}{title}{/stash:title}
        {/exp:stash:append_list}
    {/categories}
{/exp:channel:entries}

{exp:channel:categories channel="news" style="linear"}
    <h2>{category_name}</h2>
    <ul>
        {exp:stash:get_list name="item_{category_id}"}
            <li>{title}</li>
        {/exp:stash:get_list}
    </ul>
{/exp:channel:categories}

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.