Pagination on partial

In the frontend of the blog plugin I made in Builder, I need to paginate records within a Partial. It is possible ? I’m trying to use {{ ajaxPager(records) }}, but the page doesn’t update.

In main page:


{% ajaxPartial ‘site/materias/noticias’ %}

In site/materias/noticias:

[builderList artigos]
modelClass = "vsi\Materias\Models\Artigo"
scope = "scopeFeatured"
scopeValue = "{{ :scope }}"
displayColumn = "article_title"
noRecordsMessage = "No records found"
detailsPage = "-"
detailsUrlParameter = "id"
recordsPerPage = 9
pageNumber = "{{ :page }}"
sortColumn = "publish_up"
sortDirection = "desc"

==
{% set records = artigos.records %}
{% set displayColumn = artigos.displayColumn %}
{% set noRecordsMessage = artigos.noRecordsMessage %}
{% set detailsPage = artigos.detailsPage %}
{% set detailsKeyColumn = artigos.detailsKeyColumn %}
{% set detailsUrlParameter = artigos.detailsUrlParameter %}

{% for record in records %}
      <h2 class="post-title"><a href="#">{{ record.article_title }}</a></h2>
{% endfor %}

<nav class="pagination-wrap mt-60">
       {{ ajaxPager(records) }}
</nav>

Hey @valentesolucoes

I’ve had a look at this today, I don’t think the builderList supports pagination since it wants the page number to be part of the URL.

You may need to copy the pagination contents from here: modules/system/views/pagination/default.htm

Then modify them to use a custom URL that includes the page number inside the |page filter.

This is because the previousPageUrl and nextPageUrl use the GET parameter (?page=1) to specify the page number.

The Forum plugin also has another example of this:

1 Like