How to implement pagination control for content list display in Anqi CMS?

Calendar 👁️ 73

In website operation, how to efficiently display and manage a large amount of content while ensuring a smooth browsing experience is a challenge that every webmaster needs to face.AnQiCMS (AnQiCMS) provides an intuitive and powerful control capability for pagination display of content lists, allowing you to easily achieve an orderly presentation and efficient navigation of content.

To implement the pagination display of content lists, we mainly use two core tags from the Anqi CMS template: content list tags (such asarchiveList/tagDataList/commentList)and pagination tags(pagination)

Core mechanism: content list tags and pagination mode

First, you need to use the content list tag to get the required content data. For example, in the article list, we commonly usearchiveListLabel. This label not only helps you filter and sort articles, but more importantly, it provides the key parameters to enable pagination mode.

When you want to display the list content in a paginated manner, you need to specify inarchiveList(ortagDataList/commentListetc.) tags explicitlytype="page". This is to inform the Anqi CMS system that the content set you are currently retrieving needs to support pagination. For example:

{% archiveList archives with type="page" limit="10" categoryId="1" %}
    {# 循环展示文章内容 #}
{% endarchiveList %}

In the above example:

  • archivesIs the custom variable name you use to store the article data you retrieve.
  • type="page"The pagination feature has been explicitly enabled.
  • limit="10"The number of articles displayed per page is set to 10. You can adjust this number according to your actual needs.
  • categoryId="1"is an optional filter condition indicating that only articles under the category with ID 1 should be retrieved. You can also addmoduleId(Content Model ID),q(search keywords) and other parameters to further refine the content selection.

After this configuration,archivesThe variable stores not only all the articles, but also the article data on the current page.

To build pagination navigation:paginationTag

Just getting the article data on the current page is not enough to complete the pagination function, the user also needs a complete set of pagination navigation to switch pages. At this point, it is necessary to use the Anqi CMS providedpaginationLabel. This label is specially designed to cooperatetype="page"The list label is designed to intelligently generate all pagination information including total number of pages, current page number, previous and next page links.

Generally,paginationThe label follows the content list tag, for example:

{# ... archiveList 标签代码 ... #}

{% pagination pages with show="5" %}
    {# 渲染分页导航 #}
{% endpagination %}

Here, pagesIs the custom variable name you set for pagination information.show="5"This parameter controls the maximum number of page numbers displayed at the same time in the pagination navigation, for example, if you are on page 10, the navigation may display “Previous page…8, 91011, 12...Next page, showing 5 page numbers.

pagesThe variable contains rich pagination data, you can use this data to build a complete and flexible pagination navigation:

  • pages.TotalItems: Total number of articles.
  • pages.TotalPages: Total number of pages.
  • pages.CurrentPage: The current page number.
  • pages.FirstPageandpages.LastPage: It includes the names and links of the first page and last page, as well as the status of whether it is the current page.IsCurrent)
  • pages.PrevPageandpages.NextPage: If available, it includes the names and links of the previous page and next page.
  • pages.PagesThis is an array that contains detailed information of all intermediate page numbers, each page object hasName(page number),Link(Page link) andIsCurrent(whether it is the current page) property.

By traversingpages.Pagesan array and combine it with conditional judgments such as{% if item.IsCurrent %}active{% endif %}You can easily add highlight style to the current page number to enhance user experience.

Actual operation example: combination of list and pagination.

In the actual template file, the structure of your code will roughly be like this:

`twig {# Possible breadcrumbs or other content at the top of the page #}

{% archiveList archives with type="page" limit="10" categoryId="1" %} {% for article in archives %}

{{ article.Title }}

{{ article.Description }}

Release date: {{ stampToDate(article.CreatedTime, "2006-01-02") }}
{% empty %}

There are no articles in this category.

{% endfor %} {% endarchiveList %}

Related articles

How to display the list of article tags (Tag) and the related articles under each Tag?

AnQi CMS provides very flexible and powerful tools for content organization, among which tags (Tag) are a very intuitive and efficient tool.By using labels reasonably, not only can it help us better manage website content, but also significantly improve user experience and search engine optimization (SEO) effects.Next, let's take a look at how to display the list of article tags in Anqi CMS, as well as the related articles under each tag.### First step: Manage and create tags in the background Before using tags, make sure that our website content has been properly tagged

2025-11-08

How does AnQi CMS display detailed content of a single page (such as About Us, Contact Information)?

In website operation, pages such as "About Us", "Contact Information", and "Privacy Policy" play a crucial role. They are the basis for visitors to show corporate information and establish trust.AnQiCMS as an efficient content management system provides a very flexible and intuitive way to create and display the detailed content of these single pages.

2025-11-08

How to dynamically display the name, description, and link of content categories in a template?

In website operation, clearly displaying content categories not only helps users quickly find the information they need, but is also a key link to improve website usability and search engine optimization (SEO).AnQiCMS (AnQiCMS) with its flexible template engine allows us to easily dynamically call and display the names, descriptions, and links of various content categories in website templates.Today, let's delve deeper into how to achieve this goal in templates, making your website content more vivid and efficient.### Understanding Content Classification in AnQi CMS In the AnQi CMS backend management system

2025-11-08

How to retrieve and display custom parameters of content models such as articles, products, etc. in a template?

In Anqi CMS, when managing website content, we often encounter the need to display specific information in addition to standard fields such as title and text.For example, when operating an e-commerce website, in addition to the name and description of the product, it may also be necessary to display 'material', 'origin', 'warranty period', and so on;Or you may be running an information blog, where articles may need to display 'author source', 'publisher' and other information.The flexible content model design of AnQi CMS is to meet this diverse content display requirement.Today, let's delve deeper into the topic

2025-11-08

How to display custom contact information (such as phone, address, social media) in the template?

The contact information on the website is the key bridge between you and the visitors for establishing communication and trust.Whether seeking services, consulting products, or simply learning more information, clearly and accurately displaying contact information is crucial for improving user experience.AnQi CMS is an efficient and convenient content management system that provides an intuitive backend management interface and flexible template calling function, allowing you to easily manage these information and seamlessly present them on every corner of the website.This article will guide you in setting up these key contact information in Anqi CMS

2025-11-08

How to define and display different banner images for different parts of the website in AnQiCMS?

In website operation, banner images are important visual elements that attract visitor attention and convey key information.They can not only enhance the overall aesthetics of the website, but also guide users to browse specific content or participate in promotional activities.AnQiCMS provides a flexible mechanism that allows you to customize and display unique Banner images for different parts of the website, such as the homepage, various thematic category pages, or independent content pages, thereby achieving more refined visual marketing.

2025-11-08

How to use the structured data (JSON-LD) feature of Anqi CMS to enhance the search engine results display?

In today's highly competitive online environment, making a website's content stand out in search engine results pages (SERP) and attract more target users is the goal of every website operator.In addition to keyword optimization, high-quality content, and a good user experience, using structured data (JSON-LD) to "tell" search engines exactly what your content is becoming a key factor in improving website visibility and obtaining rich search results (Rich Snippets).

2025-11-08

Does AnQi CMS support direct arithmetic operations on strings or numbers within templates to affect display?

When building a website, we often need to handle various data, not just simply display it.For example, we may need to calculate the total price of goods, inventory surplus, or dynamically adjust the style of elements based on numerical size.These scenarios naturally lead to a core question: Does Anqi CMS support direct arithmetic operations on strings or numbers in templates, thereby flexibly affecting the display of content?The answer is affirmative. The AnQi CMS template engine cleverly adopts many advantages of the Django template, including direct support for arithmetic operations.

2025-11-08