Pagination Label

Description: Used to get pagination information for article lists and product lists

Usage:{% pagination 变量名称 with show="5" %}If the variable is defined as pages{% pagination pages with show="5" %}...{% endpagination %}

The pagination supports one parameter:

  • Show page number countshowCan be set to how many pages to display at most when a specific number of page numbers is specified. For exampleshow="5"Can display up to 5 pages.
  • Redefine patternprefixAdvanced features are generally not required to be set. If necessary, they should include.{page}Can be set such as:prefix="?page={page}"

The available fields for pagination are:

  • Total number of itemsTotalItems
  • Total number of pagesTotalPages
  • Current page numberCurrentPage
  • Home ObjectFirstPage
  • End Page ObjectLastPage
  • Previous Page ObjectPrevPage
  • Next Page ObjectNextPage
  • Middle page number arrayPages

Pages is an array object, so it needs to useforloop to output

Among the fields available in the pageItem within Pages:

  • Page number nameName
  • Page number linkLink
  • Is it the current pageIsCurrent
<div class="pagination">
    {% pagination pages with show="5" %}
    <ul>
        <li>总数:{{pages.TotalItems}}条,总共:{{pages.TotalPages}}页,当前第{{pages.CurrentPage}}页</li>
        <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}"><a href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a></li>
        {% if pages.PrevPage %}
            <li class="page-item"><a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a></li>
        {% endif %}
        {% for item in pages.Pages %}
            <li class="page-item {% if item.IsCurrent %}active{% endif %}"><a href="{{item.Link}}">{{item.Name}}</a></li>
        {% endfor %}
        {% if pages.NextPage %}
            <li class="page-item"><a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a></li>
        {% endif %}
        <li class="page-item {% if pages.LastPage.IsCurrent %}active{% endif %}"><a href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a></li>
    </ul>
    {% endpagination %}
</div>