Custom pagination bars

On the category page or content details page, there are data list tags, and the page attribute of these tags is set to true.

For example: `<@cms_content>、<@cms_article>、 <@cms_image>When there are pagination tabs, the page context variables will contain parameters related to pagination. These variables can be used to calculate the necessary parameters for pagination. The pagination variables are as follows:

  • ${PageTotal} Total number of items in the list data
  • ${PageSize} Number of data items per page in the list
  • ${PageNo} = Current page number, starting from 1.
  • ${FirstPage} Home URL
  • ${OtherPage} = Other pages’ URLs.{0} Placeholder. Can be replaced with the specified page number.

If there are no special pagination requirements, it is recommended to use the built-in pagination function of the system.<@page_bar>Just adjust the CSS styles slightly to make them compatible with the page layout.

Example 1

Usage scenarios: Pagination bars on the column list page.

<div class="pager">
  <#if PageTotal gt 0>
  <#assign PageCount=((PageTotal + PageSize - 1) / PageSize)?floor />
  <div class="prev">
  <#if PageNo gt 1>
    <#if PageNo==2>
    <a href="${FirstPage}"><i class="iconfont">&#xe693;</i></a>
    <#else>
    <a href="${OtherPage?replace('{0}', PageNo-1)}"><i class="iconfont">&#xe693;</i></a>
    </#if>
    <#else>
    <a href="javascript:void(0);"><i class="iconfont">&#xe693;</i></a>
  </#if>
  </div>
  <#assign startPage = max(1, min(PageCount - 6, PageNo - 3)) />
  <#assign endPage = max(startPage, min(PageCount, max(startPage + 6, PageNo + 3))) />
  <div class="nums">
    <#if startPage gt 1>
    <a href="${FirstPage}" class="cur">1</a>
    </#if>
    <#if startPage gt 2>
    <a href="javascript:void(0);">...</a>
    </#if>
    <#list startPage..endPage as pn>
      <#if PageNo==pn>
      <a class="cur" href="javascript:void(0);">${pn}</a>
      <#else>
        <#if 1==pn>
        <a href="${FirstPage}">${pn}</a>
        <#else>
        <a href="${OtherPage?replace('{0}', pn)}">${pn}</a>
        </#if>
      </#if>
    </#list>
    <#if endPage lt PageCount - 1>
    <a href="javascript:void(0);">...</a>
    </#if>
    <#if endPage lt PageCount>
    <a href="${OtherPage?replace('{0}', PageCount)}">${PageCount}</a>
    </#if>
  </div>
  <div class="next">
  <#if PageNo lt PageCount?int>
    <a href="${OtherPage?replace('{0}', PageNo+1)}"><i class="iconfont">&#xe694;</i></a>
    <#else>
    <a href="javascript:void(0);"><i class="iconfont">&#xe694;</i></a>
  </#if>
  </div>
  </#if>
</div>

Tips for use:

Create a standalone pagination template to share the same controls across multiple templates. Include it with <@cms_include> and set both ssi and cache to false, as shown below.

<@cms_include file="pagebar.template.html" ssi="false" cache="false"></@cms_include>

On this page