We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

ExpressionEngine {exp:channel:categories}, multiple category groups ordered together

Development and Programming

sambaldwin's avatar
sambaldwin
1 posts
about 13 years ago
sambaldwin's avatar sambaldwin

Is it possible to create a single alphabetically ordered list containing categories from multiple category groups?

Here is the code I am using:

<ul>
    {exp:channel:categories category_group="1|2"}
         <li>{category_name}</li>
    {/exp:channel:categories}
</ul>

Unfortunately this separates the category groups, and I end up with a list such as this:

book graphic identity poster website architecture art David Bowie ExpressionEngine zoos

You’ll notice that it is actually two lists ordered alphabetically. I would like to merge these into one list somehow.

I would expect to be able to add something like orderby= as in the Channel Entries Tag:

<ul>
    {exp:channel:categories category_group="1|2" orderby="name"}
         <li>{category_name}</li>
    {/exp:channel:categories}
</ul>

But this does not work. Has anyone come across this before?

Many thanks in advance.

       
Bransin's avatar
Bransin
157 posts
12 years ago
Bransin's avatar Bransin

Hi sam,

Have you tried GWcode Categories Plugin?

http://gwcode.com/add-ons/gwcode-categories/documentation

Another method is you can write a simple query using the query module.

Make sure the Query module is installed in your EE CP. This example pulls from category groups 1 and 2 and orders them together.

<ul>
        {exp:query sql="
        SELECT *
        FROM exp_categories
        WHERE group_id IN (1,2)
        ORDER BY cat_name ASC"}
          <li>{cat_name}</li>
        {/exp:query}
</ul>
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.