How to create pagination navigation for document lists, Tag lists, and other Anqi CMS features?

Calendar 👁️ 69

In website operation, providing clear and easy-to-use pagination navigation for content lists not only greatly enhances user experience, but also optimizes search engine crawling efficiency, helping content to be discovered better.AnQiCMS (AnQiCMS) knows this, and therefore provides powerful and flexible pagination tags in template design, allowing content operators to easily generate pagination navigation for document lists, tag lists, and so on.

Next, we will explore how to implement this feature in Anqi CMS templates, organizing your website content neatly.


Understand the core of pagination in AnQi CMS: data acquisition and navigation display

Implement the pagination function in AnQi CMS, mainly focusing on two core elements:

  1. Retrieve content list in a paginated formThis needs to use specific template tags to indicate to the system that you want to retrieve the content in batches, not all at once.
  2. Display pagination navigationOnce content is returned in a paginated form, a navigation component is needed to allow visitors to navigate between pages.

Next, let's look at the specific implementation of these steps one by one.

The first step: Get the list of paginated content

AnQi CMS providesarchiveListandtagDataListUsing these tags to get lists of content of different types. The key to enabling pagination is to add these tags.type="page"Parameters andlimitParameter.

type="page"It is a very important indicator, it tells AnQi CMS that you want the returned data to be a paginated result set.limitThe parameter is used to define how many items are displayed per page.

For example, if you want to display an article list on a category page and enable pagination, you can use it like thisarchiveListTags:

{# 假设我们正在一个分类页面,要获取该分类下的文章列表,每页显示10条 #}
{% archiveList archives with type="page" limit="10" %}
    {% for item in archives %}
        <div class="article-item">
            <h2><a href="{{item.Link}}">{{item.Title}}</a></h2>
            <p>{{item.Description}}</p>
            <span class="date">{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
        </div>
    {% empty %}
        <p>该分类下暂时没有文章。</p>
    {% endfor %}
{% endarchiveList %}

In the above code:

  • archivesIs a variable name you define to store the article data after pagination.
  • type="page"Specifically, this is a pagination query.
  • limit="10"Then, 10 articles per page were set.

Similarly, if you want to display a document list under a specific tag and enable pagination, you can usetagDataListtags, its usage is similar toarchiveListsimilarly, it also requirestype="page"andlimitParameter.

Second step: Display pagination navigation

After obtaining the pagination content, the next step is to add the actual pagination navigation links. Anqi CMS provides a very convenientpaginationThe tag will automatically generate links such as 'Home', 'Previous Page', 'Next Page', and middle page numbers based on the pagination data of the current page.

paginationTags are usually withshowParameters are used together, this parameter is used to control the number of pages displayed in the middle page link. For example,show="5"Up to 5 page number links will be displayed near the current page, ensuring the simplicity of navigation.

While usingpaginationWhen labeling, you need to define a variable (for examplepages) to receive the pagination object, which contains all the information of the current pagination state:

  • pages.TotalItems: Total number of content items.
  • pages.TotalPages: Total number of pages.
  • pages.CurrentPage: The current page number.
  • pages.FirstPageThe home page object includes:LinkandIsCurrentProperty).
  • pages.LastPage: End object (including)LinkandIsCurrentProperty).
  • pages.PrevPage: Previous page object (if exists).
  • pages.NextPage: Next page object (if exists).
  • pages.Pages: An array, containing middle page number objects (each object also has}Name/Link/IsCurrent)

The followingpaginationA typical usage example of a label:

<div class="pagination-nav">
    {% pagination pages with show="5" %}
        {# 可以显示一些分页概览信息 #}
        <span class="page-info">共 {{pages.TotalItems}} 条内容,{{pages.TotalPages}} 页,当前第 {{pages.CurrentPage}} 页</span>

        {# 首页链接 #}
        <a class="page-link {% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">首页</a>

        {# 上一页链接 - 仅当存在上一页时显示 #}
        {% if pages.PrevPage %}
            <a class="page-link" href="{{pages.PrevPage.Link}}">上一页</a>
        {% endif %}

        {# 中间页码链接 #}
        {% for item in pages.Pages %}
            <a class="page-link {% if item.IsCurrent %}active{% endif %}" href="{{item.Link}}">{{item.Name}}</a>
        {% endfor %}

        {# 下一页链接 - 仅当存在下一页时显示 #}
        {% if pages.NextPage %}
            <a class="page-link" href="{{pages.NextPage.Link}}">下一页</a>
        {% endif %}

        {# 尾页链接 #}
        <a class="page-link {% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">尾页</a>
    {% endpagination %}
</div>

By flexible combinationpagesAn attribute in an object, you can build various styles and layout pagination navigation. For example, you can judgepages.FirstPage.IsCurrentAdd links to the current page.activeAdd a class to highlight through CSS.

Comprehensive example: add pagination to the document list.

Combining the above two steps, a complete document list page with pagination in the template might look like this:

"`twig {# /template/{modeltable}/list.html or /template/search/index.html #}

{% archiveList archives with type="page" limit="10" %}
    {% for item in archives %}
        <article class="article-card">
            <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
            <p class="description">{{item.Description|truncatechars:150}}</p>
            <div class="meta-info">
                <span>发布于:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>阅读量:{{item.Views}}</span>
            </div>
        </article>
    {% empty %}
        <p class="no-content">抱歉,这里还没有相关内容。</p>
    {% endfor %}
{% endarchiveList %}

{% pagination pages with show="5" %}
    <nav aria-label="Page navigation">
        <ul class="pagination-list">
            <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}">
                <a class="page-link" href="{{pages.FirstPage.Link}}" aria-label="首页">首页</a>
            </li>
            {% if pages.Prev

Related articles

How to generate and display the breadcrumb navigation of the current page in Anqi CMS

When we browse websites, we often see a line at the top or bottom of the page indicating the current location path, such as “Home > Product Category > Electronic Products > Laptop”.This is what we commonly call 'breadcrumb navigation', which not only clearly informs us of our location but also makes it convenient for us to quickly return to the previous level page, greatly enhancing the website's user experience and navigation efficiency.In Anqi CMS, implementing and displaying breadcrumb navigation is a very easy thing to do.The system is built-in with special template tags that can intelligently adapt to the content structure of the current page

2025-11-08

How to set and display the TDK (Title, Description, Keywords) on the homepage of Anqi CMS?

In website operation, TDK (Title, Description, Keywords) play a crucial role, they are the first window for search engines to understand the content of the website, directly affecting the visibility and click-through rate of the website in search results.An optimally optimized TDK can not only improve the website's SEO performance but also accurately convey the core value of the website to potential visitors.AnQiCMS is a content management system that focuses on SEO optimization, providing users with a convenient and efficient way to set up and manage the TDK of the homepage.

2025-11-08

How to retrieve and display the contact information, phone number, address, and email of the website?

In website operation, a clear and easily searchable contact method is a key factor in building user trust and promoting communication conversion.Whether you are seeking a partner for cooperation or a user in need of help, you can quickly find you through the contact information provided on the website.AnQiCMS provides flexible and convenient functions for managing and displaying contact information, allowing you to easily obtain and display various contact information such as contacts, phone numbers, addresses, and email addresses.

2025-11-08

How to display the website name, Logo, filing number, and copyright information in Anqi CMS?

When operating a website, the website name, logo, filing number, and copyright information are core elements that constitute the brand image, establish user trust, and meet legal compliance requirements.For users of AnQiCMS, the system provides an intuitive and flexible way to manage and display this information, making your website not only rich in content but also professional and perfect in detail. ### One, centralized management: Configure these key information in the background One of the design philosophies of AnQi CMS is to make website management simple and efficient.

2025-11-08

How to implement language switching functionality for multilingual sites in Anqi CMS?

When our website is aimed at serving global customers, providing multilingual support has become an indispensable feature.This can not only help us expand the international market, but also significantly improve the access experience of users in different languages.AnQiCMS (AnQiCMS) fully understands this need, therefore, it has made multilingual support one of its core highlights, allowing us to easily build multilingual websites and switch languages.How to implement language switching for multi-language sites in AnQi CMS

2025-11-08

How to display the Banner slideshow image on the homepage or a specific group?

The homepage and banner carousel images of specific groups, which are key elements in attracting visitors and displaying core content on the website.A convenient and flexible system for management and display, which can greatly improve the operation of your website.AnQiCMS (AnQiCMS) takes advantage of its intuitive design and powerful template tag features, allowing you to effortlessly handle these visual elements, whether it's creating an eye-catching homepage image or customizing exclusive promotional images for specific category pages, you can do so with ease.

2025-11-08

How to customize or override the JSON-LD structured data in AnQi CMS?

The AnQi CMS has always been committed to providing efficient and flexible solutions in content operation and search engine optimization.Structured data, especially JSON-LD, is an important means to improve the visibility of website content in search engines.It can help search engines understand the page content more accurately, thereby giving it the opportunity to display richer search results (i.e., rich media summaries) and attract more users to click. AnQi CMS understands the importance of structured data, and has preset some default JSON-LD structured data for you in the system design.

2025-11-08

How to obtain the background custom global parameters in the template?

In AnQi CMS, the flexibility and maintainability of the website are one of its core advantages.Content operators and developers often need to dynamically adjust some global information of the website without modifying the template code, such as the company name, contact number, and even some marketing campaign links.These are the background custom global parameters that are the key to achieving this requirement.Today, let's delve into how to easily obtain and display these custom global parameters configured in the Anqi CMS template.### Why do we need global parameters? Imagine that

2025-11-08