1

How can I output the entry_ids for multiple channels within a category loop organized by channel?

I have 3 channels that share a category group so I need to loop through the categories and list out all entry ids but organized by their channel.

The info needs to be like so:

category 1 title
  - channel 1 (entry id 1, entry id 2, etc)
  - channel 2 (entry id 1, entry id 2, etc)
  - channel 3 (entry id 1, entry id 2, etc)

category 2 title
  - channel 1 (entry id 1, entry id 2, etc)
  - channel 2 (entry id 1, entry id 2, etc)
  - channel 3 (entry id 1, entry id 2, etc)

Hope that makes sense.

Any help is appreciated.

1
{exp:channel:categories}
   {category_name}
   {exp:channel:entries category="{category_id}" channel="channel1"}
      {if count == 1}{channel}{/if}
      {title}
   {/exp:channel:entries}
   {exp:channel:entries category="{category_id}" channel="channel2"}
      {if count == 1}{channel}{/if}
      {title}
   {/exp:channel:entries}
   {exp:channel:entries category="{category_id}" channel="channel3"}
      {if count == 1}{channel}{/if}
      {title}
   {/exp:channel:entries}
{/exp:channel:categories}

Beware performance issues if you have many categories and many entries!

Other ways just for the sake of it...

{exp:channel:categories}
   {category_name}
   {exp:channel:entries category="{category_id}" channel="channel1|channel2|channel3"}
      {channel}
      {title}
   {/exp:channel:entries}
{/exp:channel:categories}

Or reverse it:

{exp:channel:entries category="1|2|3" dynamic="no"}
    {categories}category_name{/categories}
    {channel}
    {title}
{/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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