Perch documentation

Pagination

When using perch_content_custom() to paginate the returned data you must also add some markup to your template to display the paging.

Example

<perch:after>
  <perch:if exists="paging">
    <div class="paging">
      Page <perch:content id="current_page" type="hidden" /> of <perch:content id="number_of_pages" type="hidden" />
      <perch:if exists="not_first_page">
        <a href="<perch:content id="prev_url" type="hidden" encode="false" />">Previous</a>
      </perch:if>
      <perch:if exists="not_last_page">
        <a href="<perch:content id="next_url" type="hidden" encode="false" />">Next</a>
      </perch:if>
    </div>
  </perch:if>
</perch:after>

Pagination template variables

ID Purpose
paging Set if paging is present. Can be testing for with a perch:if tag.
total The total number of items in the result set.
number_of_pages The number of pages the result set is split into.
total_pages Same as number_of_pages. (Compatibility)
per_page Number of results per page.
current_page The current page in the result set.
lower_bound The first record index on this page.
upper_bound The last record index on this page.
prev_url The URL of the previous page. Empty for the first page.
next_url The URL of the next page. Empty for the last page.
prev_page_number The page number of the previous page. Empty for the first page.
next_page_number The page number for the next page. Empty for the last page.
not_first_page Present and set if the current page is not the first page in the set.
not_last_page Present and set if the current page is not the last page in the set.