Create a specific order of paginated entries by entry type

I am working with a design that requires entries to be laid out on a listing page in a specific order based on whether they are "Standard" or "Premium". The order of the paginated listing page is as follows:

• Standard, Standard, Standard, Standard
• Standard, Standard, Standard, Standard
• Pagination

There could be a number of approaches with how I store the entries but my approach has been to set up a channel section "Offers" with two entry types "Standard" and "Premium". If the layout was not important I have the following working:

{% paginate craft.entries.section('offers').limit(14) as pageInfo, pageEntries %}

{% for entry in pageEntries %}
{% if entry.type == 'premium' %}
{% endif %}
{% if entry.type == 'standard' %}
{% include "_includes/offers/listing-card" %}
{% endif %}
{% endfor %}

{# PAGINATIOIN NAV HERE #}


My question is, how do I achieve the above but using the specific order I need, whilst still paginating the entries and keeping track of what's been displayed.

If I get you right, you want to exclude the premium entries from the others? Carefull, code is not tested ;)

{% set premiumEntries = craft.entries({
section: 'offers',
order: 'postDate desc'
}) %}

{% set standardEntries = craft.entries({
section: 'offers',
entry-type: 'standard',
order: 'postDate desc'
}) %}


Then you need to do a loop to merge the standard to the premium. Something like this Merge two arrays of ElementModels?

... and finally paginate trough all of them. Hope that helps.

• Thanks Jan, any ideas, once I have merged the arrays in how to get that specific order. There is an almost identical question here: craftcms.stackexchange.com/questions/21732/… but no real answer. – Gareth Aug 27 '17 at 17:16
• wrong link maybe? ;) – Jan Aug 27 '17 at 17:28
• Oops infinite question loop error ;-) craftcms.stackexchange.com/questions/14002/… – Gareth Aug 27 '17 at 17:49
• ok, now I get exactly what you are trying to do. As I explained in my answer before I what seperate the entries first and them merge them together in a third object. So as I your order is not exactly systematic I would make a loop based on the premiumEntries object and with a simple if = 3 or 7 or 10 (if I counted right) I would merge an additional premiumEntries Entry to the new (third) object. – Jan Aug 27 '17 at 20:15