How to implement pagination display for the document list with `pagination` tag?

Calendar 👁️ 87

As an experienced website operations expert, I know that an efficient content management system (CMS) plays a foundational role in website operations.AnQiCMS boasts its concise and efficient architecture and rich features, performing excellently in content publishing and management.Today, let's delve deeply into a seemingly simple yet extremely important feature of AnQiCMS -paginationHow a tag can elegantly implement pagination of document lists, thereby optimizing user experience and enhancing website performance.

AnQiCMS Deep Guide to Pagination Function: Skillfully UtilizedpaginationTag implementation for document list pagination

In content management, when the list content such as articles, products, or comments increases, if there is no effective pagination mechanism, users will face the problem of information overload, and the website loading speed will also be affected. AnQiCMS understands this well and provides a set of intuitive and flexible pagination solutions, the core of which is its powerfulpagination.

Understand the pagination mechanism of AnQiCMS:paginationCollaboration with list tags

Firstly, we need to make it clear that:paginationThe tag does not operate independently, it always collaborates closely with the tags used in AnQiCMS to obtain content lists, for examplearchiveList(Document list),commentList(Comment list) ortagDataList(Tag document list). When you set the parameters in these list tags,type="page"AnQiCMS will automatically prepare the data needed for pagination of the current list. At the same time,limitThe parameter allows you to precisely control the number of documents displayed per page. For example,{% archiveList archives with type="page" limit="10" %}This code will not only retrieve the first 10 documents but also prepare the pagination information for all documents, providingpaginationlabel usage

paginationCore function and parameter explanation of the tag

Once the list label is ready with the pagination data,paginationThe tag shines on the stage, responsible for presenting these pagination information in a readable and clickable page number form on the front-end page. Its basic usage format is{% pagination pages with show="5" %}of whichpagesIs a variable name you define, used to receive pagination data;showIs a very practical parameter that determines how many page number links are displayed before and after the current page number. For example,show="5"It means that in the pagination navigation, at most 5 page numbers will be displayed (excluding "Home page", "End page", etc.), which will usually intelligently expand around the current page number to maintain the simplicity of navigation.

AnQiCMS'paginationThe tag also provides an advanced parameter.prefix. If you need to customize the pagination URL structure in an unconventional way, for example, by using the default?page=2changed to?p=2, you can take advantage ofprefix="?p={page}"To implement. However, in most standard application scenarios, the default URL structure of AnQiCMS is already friendly, thereforeprefixThe parameters usually do not need to be manually set.

In-depth understanding of pagination data structure:pagesRich information of variables

When you usepaginationLabel and assign pagination data topagesThis variable after,pagesAn object will contain a series of useful information, convenient for us to build a complete pagination navigation.

Firstly, it will provide global statistics, such asTotalItems(Total document count),TotalPages(Total number of pages) as well asCurrentPage(Current page number). This information can be used to display statistics like 'Total XX items, Page Y/Z' at the bottom of the page, helping users understand the overall scale of the current list.

Next,pagesThe variable will also provide a series of convenient navigation link objects, includingFirst Page(Home page),Last Page(End Page)、Previous Page(Previous page) andNext Page(Next page). Each navigation link object includesName(Link text, such as “Home”, “Previous page”),Link(The actual URL address) andIsCurrent(A boolean value indicating whether it is the current page) and other properties. By determiningIsCurrentproperties, we can add a highlight style to the current page number to enhance user experience.

The most core isPagesattribute, it is an array that contains the list of page numbers in the middle section. You need to traverse thisPagesAn array to render each page link, each array item also containsName/LinkandIsCurrentproperties. These fields make it easy to build dynamic and functional pagination navigation.

The practical application of pagination: building a complete document list pagination

To better illustratepaginationThe actual application of tags, let's see a combinationarchiveListImplement a typical code example for document list pagination. Assume we want to display 10 articles per page on the page and provide pagination navigation:

{# 1. 使用 archiveList 获取文档列表并准备分页数据 #}
{% archiveList archives with type="page" limit="10" %}
    <div class="article-list">
        {% for item in archives %}
        <article class="post-item">
            <h2><a href="{{ item.Link }}">{{ item.Title }}</a></h2>
            <p>{{ item.Description }}</p>
            <div class="meta">
                <span>发布于:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                <span>阅读量:{{ item.Views }}</span>
            </div>
        </article>
        {% empty %}
        <p>当前分类下暂无文章。</p>
        {% endfor %}
    </div>

    {# 2. 使用 pagination 标签生成分页导航 #}
    <nav class="pagination-nav">
        <ul>
            {% pagination pages with show="5" %}
            {# 显示首页链接 #}
            <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>
            {% endpagination %}
        </ul>
    </nav>
{% endarchiveList %}

In this code block,archiveListresponsible for fetching data and informing the system that pagination is required (type="page") thereafter,paginationTag usagepagesvarious information contained in the variable dynamically generates a complete page navigation. Through conditional judgment ({% if %}and{% if item.IsCurrent %}), we can ensure that the 'Previous/Next page' links are only displayed when necessary, and a special style is added to the current page number.

**Practical and Advanced Techniques**

  • Always usetype="page"This is the key to trigger the AnQiCMS to generate pagination data. If it is forgotten to set,paginationthe tag will not be able to get any pagination information.
  • Reasonable settingslimitwithshow:limitControl the number of items displayed per page, which directly affects the user's browsing experience and page loading speed.showIt controls the length of page navigation to avoid redundancy due to too many page numbers. Adjust according to the website content and user habits.
  • CSS style customization:paginationThe tag only generates HTML structure, and its appearance is completely controlled by frontend CSS.This provides designers with a great degree of freedom, allowing them to customize the design according to the overall style of the website.
  • SEO friendly: AnQiCMS usually follows SEO **practices when generating pagination URLs, such as in

Related articles

How to call the document's Tag list with `tagList` tag?

## The Powerful Assistant for Content Operation: The Clever Use of `tagList` Tag in AnQiCMS In the vast sea of the Internet, how to efficiently organize information, make it easy to find, and ultimately reach the target users accurately is a problem that every content operator is thinking about. AnQiCMS (AnQiCMS), as a content management system designed for enterprises and self-media, understands this pain point and provides powerful tools such as `tagList` in its powerful template tag system, helping us easily master content tags and add the charm of classification and aggregation to the website.

2025-11-07

How to get the specified model or sub-categories under the parent category of the `categoryList` tag?

## Taming AnQiCMS `categoryList` tag: How to efficiently obtain the specified model and subcategories under the parent category In the daily operation of AnQiCMS, content classification is the core of the website structure, which not only relates to the smoothness of the user's browsing experience but is also a key element that cannot be ignored in search engine optimization (SEO). In order to help everyone better manage and display website content, today we will delve into a very practical and powerful template tag in AnQiCMS——`categoryList`

2025-11-07

How to implement navigation between previous and next document sections using the `prevArchive` and `nextArchive` tags?

## Easily Navigate: How to Use `prevArchive` and `nextArchive` Tags for Smart Article Navigation in AnQiCMS As an experienced website operator, we know that website content is not just about publishing. How to allow users to smoothly browse through massive amounts of information and find the next article they are interested in is crucial for improving user experience, extending stay time, and even optimizing SEO. In the powerful and flexible content management system AnQiCMS (AnQiCMS)

2025-11-07

How to use the `archiveDetail` tag to get detailed information of a specific document?

As an experienced website operation expert, I know that content is the soul of the website, and how to efficiently and accurately present these contents is an indispensable part of our daily work.In such a powerful content management system as AnQiCMS, making good use of the template tags provided can greatly enhance our content operation efficiency.

2025-11-07

What specific features does the 'Content Management' module of AnQiCMS backend contain?

As an experienced website operations expert, I know that content is the soul of the website, and an efficient, flexible content management system (CMS) is the core engine that drives the lifecycle of website content.AnQiCMS (AnQi CMS) performs excellently in this regard, and its "Content Management" module is undoubtedly one of the most powerful and favored features by operators.

2025-11-07

How to add a new document and set recommended attributes, keywords, and SEO titles in AnQiCMS?

## AnQiCMS Content Operation Manual: Easily add documents to achieve double benefits of SEO and user experience As an experienced website operation expert, I am well aware of the importance of an efficient and intelligent content management system for enterprises and self-media.AnQiCMS (AnQiCMS) is gaining popularity among operators with its high-performance architecture developed in Go language and rich content management features.It not only makes content publishing simple, but also deeply integrates SEO optimization into daily operations, helping your website stand out in the fierce market competition.

2025-11-07

What advanced features does the AnQiCMS document content editor support, such as the material library and image resources?

In the daily operation of AnQiCMS (AnQiCMS), we understand that an efficient and intelligent content editor is the core driver of content productivity.It is not just a tool for text input, but also a bridge for content creators and operators to transform thoughts into high-quality content.AnQiCMS designed its content editor by precisely perceiving this need, and tirelessly integrated a variety of advanced features, especially in the material library and image resource management, demonstrating its meticulous craftsmanship in improving operational efficiency.### The foundation of content editor: A powerful and intuitive editing experience First

2025-11-07

How to customize document categories in AnQiCMS and set category templates and SEO information?

As a veteran in website operation for many years, I deeply understand the importance of a flexible and efficient content management system for website operation.AnQiCMS (AnQiCMS) boasts its high-performance architecture based on the Go language, rich customization features, and deep optimization for SEO, and is undoubtedly a powerful assistant for small and medium-sized enterprises and content operation teams.It not only makes content management simple, but also allows every corner of the website to bear the power of optimization.

2025-11-07