Pagination Tags

Description: Used to obtain paging information for article list and product list

How to use:{% pagination 变量名称 with show="5" %}If you define a variable as pages{% pagination pages with show="5" %}...{% endpagination %}

pagination supports one parameter:

  • Display page number numbershow
    You can set the maximum number of page numbers to display when specifying the number of page numbers. likeshow="5"Up to 5 pages can be displayed.
  • Redefine patternprefix
    Advanced features generally do not require settings. If necessary, it is necessary to include{page}, can be set as follows:prefix="?page={page}"

The available fields are:

  • Total number ofTotalItems
  • Total page numberTotalPages
  • Current page numberCurrentPage
  • Home ObjectFirstPage
  • Last page objectLastPage
  • Previous page objectPrevPage
  • Next page objectNextPage
  • Middle page number arrayPages

Pages is an array object, so it needs to be usedforLoop to output

The fields available for pageItem in Pages are:

  • Page number nameName
  • Page number linkLink
  • Whether 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>