2

I have banner ads stored in a channel and these are associated using a single entry Playa field with clients stored in another. I need to display random banners on a page but without ever showing more than one banner from each client.

Channel entries has no concept of 'Group By' so how am I best to go about doing this?

Update

In the end I wrote an extension to do this though the answer below would work equally well. You can download the 'Group By' extension here - https://github.com/ninefour/group_by.ext.ee_addon

3

I would use Stash to do this. See the example on the Stash wiki about grouping by with categories, which should work similar for the Playa field you have.

Within a banner's loop first create a stash list (by appending) of the banner ads with the client's id in name, something like

{exp:stash:append_list name="banner_{*playa field client entry id tag*}"}

then within a client's loop output the stash list, limiting the amount of banners to 1, like

{exp:stash:get_list name="banner_{*playa field client entry id tag*}" limit="1"}
3

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.