2

I'm looping through multiple Channels:

{exp:channel:entries channel="channel_a|channel_b"}

Say that channel_a has a_field and channel_b has b_field. I want to sort such that the values of a_field and b_field are consider part of the same list. I don't want to, say, sort all the a_field first, then all the b_field next.

Possible to do this in EE?

2
  • Simple question: can't you use the same field group to both channels? – Sobral Jul 20 '13 at 13:48
  • Unfortunately, no. It's not an option for me. Should I enable PHP in the template and try to do this in PHP? – ExpressionEngineNewbie Jul 20 '13 at 22:51
3

This looks like a job to Stash!

{exp:stash:set_list name="channels_a_and_b" parse_tags="yes"}
    {exp:channel:entries channel="channel_a|channel_b"}
                {stash:sort_field}{a_field}{b_field}{/stash:sort_field}
                {stash:another_field_a}{another_field}{/stash:another_field_a}
                {stash:another_field_b}{another_field}{/stash:another_field_b}
                [...]
    {/exp:channel:entries}
{/exp:stash:set_list}

Then, on an embed:

{exp:stash:get_list name="channels_a_and_b" orderby="sort_field"}
    {sort_field}
    {another_field_a}
    {another_field_b}
    [...]
{/exp:stash:get_list}

Just, please, don't get addicted to Stash. I have seen a lot of unnecessary and complex uses of Stash around there.

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.