Using EE v2.8.1

I need to display a list of entries, split into 4 groups, the entries should be randomised within each group (entries are grouped on a custom field value, which can be between 1 and 4).

All entries need to be displayed. They also need to be paginated, 9 entries at a time (this is done using Ajax).

They should be presented in order of group:

  group 4 entries (randomised)
  group 3 entries (randomised)
  group 2 entries (randomised)
  group 1 entries (randomised)

Groups may contain any number of entries.

I'm using stash but I can't think of a way to fetch only those entries that are to be displayed on a page, the only method I can think of is to fetch the whole list.


Not so clear from your question what you plan to do - specifically is the plan to show just one entry in each group at a time and repeat the four group entries over and over, or show all the entries in group 1 first, and then all the entries in group 2... etc.?

Either way, one way you could do this is to put each group of entries (or just the pagingated sub-set for each group) into a layout variable array and then recall these in whatever format / sequence you want.

Also usually helpful to state what version of EE you are using.

Storing layout variables is quite efficient, can work nicely with the template debug in EE 5, and usually less confusing to implement than stash equivalents, as the parsing of the variables is done consistently at the point were template processing transfers to the next template in the layout sequence.

The documentation for layout variables in the latest EE5 documentation is much improved over earlier versions, and should be enough if you are not already familiar with the approach. If you need some guidance on how to code this up, provide a bit more information about what actually you are trying to generate and maybe it will be possible to give you some example ideas.

  • Thank you for responding, I've updated my question to include some of the info you said was missing. Unfortunately I'm stuck with EE 2! Jul 2 '19 at 7:36

This was a lot easier than I thought, I was ordering by 2 fields, the group field and then title, I removed title and the list is ordered correctly just by group and orders for the entire record set even though I'm paginating.

(Ordering by 2 fields seems to force the sorting to be only within each page, not for the entire recordset.)

I then create 4 stash lists grouped by partner level.

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.