<p>Well after a brain melting, I have come up with an answer, im not sure how pretty it is, any comments on how to tidy it up are most welcome.</p>
<pre><code>&lt;!-- get the premium entries and randomize --&gt;
{% set premEntries = craft.entries.section(&quot;test&quot;).relatedTo(category).Premium('yes').orderBy('RAND()').ids() %}

&lt;!-- get the standard entries and randomize --&gt;
{% set standEntries = craft.entries.section(&quot;test&quot;).relatedTo(category).Premium('no').orderBy('RAND()').ids() %}

&lt;!-- get the total number of premium entries --&gt;
{% set premCount = craft.entries.section(&quot;test&quot;).relatedTo(category).Premium('yes').orderBy('RAND()').count() %}

&lt;!-- Divide total premium entries by Pagination per page limit --&gt;
{% set limitTotal = premCount / 12 %}

&lt;!-- Round up the linitTotal, this gives me page the premium entries finish on --&gt;
{% set limitRoundUp = ceil(limitTotal) %}

&lt;1-- This gives me the number of premium entries on the last page they appear --&gt;
{% set limitRoundDown = floor(limitTotal) %}
{% set lim3 = limitRoundDown * 12 %}
{% set lim4 = premCount - lim3 %}


&lt;!-- This merges the 2 sets of entries together into the paginated results --&gt;
{% set allEntries = standEntries |merge(premEntries) %}
{% set posts = craft.entries.id( allEntries ) %}
{% paginate posts.limit(12).orderby('Premium desc') as pageInfo, pageEntries %}     
{% set pageCount = pageInfo.totalPages %}


&lt;!--  This turns the grey background white on page 2 and beyond if there are less that 12 premium entries --&gt;
    &lt;div class=&quot;container-fluid greyouter {% if premCount &lt;= 12 %}whiteouter{% endif %}&quot;&gt;       
        &lt;div class=&quot;container&quot;&gt;
                &lt;div class=&quot;row&quot;&gt;
            
                {% for entry in pageEntries %}
                
                
    &lt;!-- this is the styling for the above, must be inside the FOR statement to be able to register the current page --&gt;    

    
                    {% if pageInfo.currentPage != '1' %}
                        &lt;style&gt;
                            .whiteouter {
                                background-color: #fff;
                                        }
                        &lt;/style&gt;
                    {% endif %}
                    
                    
    &lt;!-- this is the styling for if page 1 has no premium entries, it changes the background to white, must be inside the FOR statement to be able to register the current page --&gt; 
    
    
        {% if pageInfo.currentPage == '1' and premCount == '0' %}
            &lt;style&gt;
                .greyouter              {
                background-color: #fff;
                        }
        &lt;/style&gt;
        {% endif %}
    &lt;div class=&quot;col-lg-4 pb-5&quot;&gt; 
                
        &lt;div class=&quot;vendorboximg&quot;&gt;
            
        &lt;/div&gt;
        
        
    &lt;/div&gt;  


&lt;!--  This checks to see if this page is where the premium entries stop, and if this loop is the last premium, if so it adds a new row, no CSS required as backgorund is white anyway --&gt;

    {% if pageInfo.currentPage == limitRoundUp and loop.index == lim4 %}
     &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;container-fluid pt-5&quot;&gt;&lt;div class=&quot;container&quot;&gt;&lt;div class=&quot;row&quot;&gt;{% endif %}


{% endfor %}
&lt;!-- Pagination numbers --&gt;
&lt;div style=&quot;width:100%&quot;&gt;
    {% include 'includes/_sect-pagination' %}
  &lt;/div&gt;              
</code></pre>

CC BY-SA 4.0
2021-01-22T00:55:18.760Z
2021-01-22T00:55:18.760Z
springboynick
<pre><code>{% set query = craft.entries.businessAddress(params).orderBy('Premium desc, distance').limit(12) %}

{% paginate query as pageInfo, pageEntries %}

&lt;div class=&quot;row&quot;&gt;
        
    {% for entry in pageEntries %}

        &lt;div class=&quot;col-lg-4&quot;&gt;  

            &lt;div class=&quot;DETAILS   {% if premium == 'yes' %}  {% endif %}&quot;&gt; 
            &lt;!--- DETAILS --&gt;
            &lt;/div&gt;

        &lt;/div&gt;

    {% endfor %}

{% include 'includes/_sect-pagination' %}

&lt;/div&gt;
</code></pre>
<p>I have the above code, which outputs paginated results of a section ordered by whether they are a STANDARD or PREMIUM entry, then by a distance calculation.
Within the entry output an IF statement adds more CSS to the output depending if STANDARD or PREMIUM, all of this works fine, however, id like to add more CSS to the results.</p>
<p>I would like to have the PREMIUM entries output in a separate ROW to the STANDARD entries so the ROWS can have different CSS applied, but still remain part of the total pagnination.</p>
<p>For example, if there are 3 premium and 14 standard,</p>
<p>The first page would be:-</p>
<pre><code>&lt;div class=&quot;row premiumrow&quot;&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;PREM ENTRY 1&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;PREM ENTRY 2&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;PREM ENTRY 3&lt;/div&gt;
</code></pre>

<pre><code>&lt;div class=&quot;row standardrow&quot;&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 1&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 2&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 3&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 4&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 5&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 6&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 7&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 8&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 9&lt;/div&gt;
</code></pre>

<p>Second page would be:-</p>
<pre><code>&lt;div class=&quot;row standardrow&quot;&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 1&lt;/div&gt;
&lt;did class=&quot;col-lg-4&quot;&gt;STANDARD ENTRY 2&lt;/div&gt;
</code></pre>

<p>Can anyone say if that is possible within paginated results, if so how?</p>
<p>Any help would be greatly appreciated.</p>

<craft3><pagination><css>
Multiple Queries with differing CSS in Paginated output
# Multiple Queries with differing CSS in Paginated output

(Asked by: username_0 on 2021-01-21)

{% set query = craft.entries.businessAddress(params).orderBy('Premium desc, distance').limit(12) %}

{% paginate query as pageInfo, pageEntries %}


        
    {% for entry in pageEntries %}

          

             
            
            

        

    {% endfor %}

{% include 'includes/_sect-pagination' %}



I have the above code, which outputs paginated results of a section ordered by whether they are a STANDARD or PREMIUM entry, then by a distance calculation.
Within the entry output an IF statement adds more CSS to the output depending if STANDARD or PREMIUM, all of this works fine, however, id like to add more CSS to the results.
I would like to have the PREMIUM entries output in a separate ROW to the STANDARD entries so the ROWS can have different CSS applied, but still remain part of the total pagnination.
For example, if there are 3 premium and 14 standard,
The first page would be:-

PREM ENTRY 1
PREM ENTRY 2
PREM ENTRY 3


STANDARD ENTRY 1
STANDARD ENTRY 2
STANDARD ENTRY 3
STANDARD ENTRY 4
STANDARD ENTRY 5
STANDARD ENTRY 6
STANDARD ENTRY 7
STANDARD ENTRY 8
STANDARD ENTRY 9

Second page would be:-

STANDARD ENTRY 1
STANDARD ENTRY 2

Can anyone say if that is possible within paginated results, if so how?
Any help would be greatly appreciated.

**Tags:** craft3, pagination, css

---

## 1 answers

### Answer by username_0 on 2021-01-22. Score: 1 | Accepted answer

Well after a brain melting, I have come up with an answer, im not sure how pretty it is, any comments on how to tidy it up are most welcome.

{% set premEntries = craft.entries.section("test").relatedTo(category).Premium('yes').orderBy('RAND()').ids() %}


{% set standEntries = craft.entries.section("test").relatedTo(category).Premium('no').orderBy('RAND()').ids() %}


{% set premCount = craft.entries.section("test").relatedTo(category).Premium('yes').orderBy('RAND()').count() %}


{% set limitTotal = premCount / 12 %}


{% set limitRoundUp = ceil(limitTotal) %}

<1-- This gives me the number of premium entries on the last page they appear -->
{% set limitRoundDown = floor(limitTotal) %}
{% set lim3 = limitRoundDown * 12 %}
{% set lim4 = premCount - lim3 %}



{% set allEntries = standEntries |merge(premEntries) %}
{% set posts = craft.entries.id( allEntries ) %}
{% paginate posts.limit(12).orderby('Premium desc') as pageInfo, pageEntries %}     
{% set pageCount = pageInfo.totalPages %}



           
        
                
            
                {% for entry in pageEntries %}
                
                
        

    
                    {% if pageInfo.currentPage != '1' %}
                        
                    {% endif %}
                    
                    
     
    
    
        {% if pageInfo.currentPage == '1' and premCount == '0' %}
            
        {% endif %}
     
                
        
            
        
        
        
      




    {% if pageInfo.currentPage == limitRoundUp and loop.index == lim4 %}
     {% endif %}


{% endfor %}


    {% include 'includes/_sect-pagination' %}


---

