Back to SiteSearch Support

petermezes
petermezes

Hi,

I would like to ask about the pagination. I have added your plugin into my site (works great btw, thank you!) and customised the templates as needed.

Just pagination is bit more tricky, because it is generated "somewhere" just displayed via {{ results | raw }}. So, can you please point me where this generating happens? I wasn't able to find it and would like to change it to my custom appearance.

Thank you..

OFFLINE
OFFLINE

This is where the magic happens: https://github.com/OFFLINE-GmbH/oc-site-search-plugin/blob/develop/components/SearchResults.php#L204

You'll get a standard LengthAwarePaginator instance. You can use all the methods documented in the Laravel docs in your view partial and don't have to simply cast it to a string with the raw filter.

petermezes
petermezes

Awesome! Thank you very much.

Was pretty easy :) In case someone will need, here is snippet of my pagination.htm so it needs just custom styles as needed.

{% if results.lastPage > 1 %}
<ul class="pagination">

    {% if results.currentPage > 1 %}
        <li>
            <a class="button " href="{{ results.previousPageUrl }}"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
        </li>
    {% else %}
        <li>
            <a class="button disabled" href="nojavascript...void(0)"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
        </li>
    {% endif %}

    {% for page in 1..results.lastPage %}
    <li>
        <a 
            class="page {{ results.currentPage == page ? 'active' : null }}" 
            href="{{ this.page.baseFileName | page }}?q={{ searchResults.query }}&amp;page={{ page }}">
            {{ page }}
        </a>
    </li>
    {% endfor %}

    {% if results.lastPage > results.currentPage %}
        <li>
            <a href="{{ results.nextPageUrl }}" class="button"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
        </li>
    {% else %}
        <li>
            <a href="nojavascript...void(0)" class="button disabled"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
        </li>
    {% endif %}

</ul>
{% endif %}
Sam
Sam

petermezes said:

Awesome! Thank you very much.

Was pretty easy :) In case someone will need, here is snippet of my pagination.htm so it needs just custom styles as needed.

{% if results.lastPage > 1 %}
<ul class="pagination">

   {% if results.currentPage > 1 %}
       <li>
           <a class="button " href="{{ results.previousPageUrl }}"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
       </li>
   {% else %}
       <li>
           <a class="button disabled" href="nojavascript...void(0)"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
       </li>
   {% endif %}

   {% for page in 1..results.lastPage %}
   <li>
       <a 
           class="page {{ results.currentPage == page ? 'active' : null }}" 
           href="{{ this.page.baseFileName | page }}?q={{ searchResults.query }}&amp;page={{ page }}">
           {{ page }}
       </a>
   </li>
   {% endfor %}

   {% if results.lastPage > results.currentPage %}
       <li>
           <a href="{{ results.nextPageUrl }}" class="button"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
       </li>
   {% else %}
       <li>
           <a href="nojavascript...void(0)" class="button disabled"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
       </li>
   {% endif %}

</ul>
{% endif %}

Thanks Peter!

luis.mayta34292
luis.mayta34292

I understand your file but what did you place or what did you call your file on your page?

docu2931641
luis.mayta34292
luis.mayta34292

At last I understood, you must create the partial file with the paging variables and attach it to your sheet, it is very easy I like october

Last updated

1-7 of 7