How to apply AnQiCMS pagination feature to the pagination display of article lists or Tag document lists?

Calendar 👁️ 63

In website content management, whether it is to display a large number of articles, products, or documents under categories, an efficient and user-friendly pagination feature is crucial.It not only allows users to easily browse a large amount of content, avoiding the slow loading caused by long pages, but also helps search engines better crawl and index website information.AnQiCMS (AnQiCMS) is well-versed in this, providing an intuitive and powerful pagination feature in template tag design, making it easy to implement pagination display in article lists or Tag document lists.

To understand how AnQiCMS implements pagination, we need to focus on three core template tags:archiveList(used for article lists),tagDataList(used for Tag document lists) as well.pagination(Used to generate pagination navigation). They work together to build a complete pagination experience.

I. Pagination display of article list.

For the most common articles (or product) lists on the website, AnQiCMS usesarchiveListtags to retrieve content. The key to enabling pagination functionality lies intypeParameter settings.

when we wantarchiveListWhen a label returns paginated data instead of a simple list, you need totypethe parameter to"page". At the same time,limitThe parameter is no longer a limit on the total number of items, but defines the number of articles displayed per page. For example, if we want to display 10 articles per page, we can call it like this:

{% archiveList archives with type="page" limit="10" %}
    {# 在这里循环显示当前页的文章内容 #}
    {% for item in archives %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
    {% endfor %}
{% endarchiveList %}

OncearchiveListtags totype="page"The pattern is called, the AnQiCMS system will automatically handle the logic of the current page number and prepare all the data needed for pagination. Next, we can usepaginationTags to render pagination.

paginationTags usually follow.archiveListAfter the label, and pass a variable (usually namedpagesThis variable contains all the information related to pagination, such as total number of items, total number of pages, current page number, home link, previous page link, next page link, last page link, and the list of middle page numbers.showParameters allow us to control the number of middle page links displayed, for exampleshow="5"This means that up to 5 middle page numbers can be displayed.

<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>

By combining the above, we can see a functionally complete pagination navigation of the article list on the website front-end. In addition,archiveListit also supportsmoduleId(Specify the content model),categoryId(specified category),order(Sorting methods) and other parameters, which can be used to refine the selection and sorting of list data when retrieving data, and these conditions remain effective in pagination mode. If the URL contains a search keywordq,archiveListIntype="page"The search function will also be automatically read and applied.

Second, the pagination display of Tag document list.

Similar to the article list, when we need to display a document list under a specific Tag and implement pagination, we can usetagDataListTag. Its pagination logic isarchiveListhighly consistent.

tagDataListThe tag also needs totypethe parameter to"page"enable pagination mode,limitThe parameter defines the number of Tag documents to display per page. Moreover,tagIdThe parameter specifies which Tag's documents need to be retrieved.

{% tagDataList archives with type="page" limit="10" %}
    {# 在这里循环显示当前页的Tag文档内容 #}
    {% for item in archives %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
    {% endfor %}
{% endtagDataList %}

Later, it is also used topaginationBuild the pagination navigation of the Tag document list, its usage is exactly the same as the pagination of the article list.

<div class="pagination">
    {% pagination pages with show="5" %}
    <ul>
        {# 分页导航结构与文章列表分页示例一致 #}
        {# ... (省略具体代码,同上) ... #}
    </ul>
    {% endpagination %}
</div>

tagDataListalso supportsmoduleIdandorderParameters such as this allow for more flexible control of the display content and order of the Tag document list.

Section 3: Flexible Customization and Precautions.

The pagination function of AnQiCMS is designed to be very flexible, allowing template developers to adjust the style of pagination links as needed. Due topaginationThe label only provides data structure and links, the actual HTML structure and CSS style are freely defined by developers in the template, which means you can completely control the appearance and layout of the pagination buttons, making them perfectly integrate into the overall design of the website.

It is worth mentioning that when configuring pseudo-static rules, AnQiCMS will automatically adapt the URL structure of pagination links, without the need for additional cumbersome configuration for pagination rules.paginationlabel'sprefixThe parameters allow for advanced customization of pagination URL patterns, but in most cases, the automatic adaptation provided by the system is sufficient.

In general, AnQiCMS provides a comprehensive pagination solution for content lists and Tag document lists through concise and powerful template tags.Developers only need to understand the usage of a few core tags to quickly implement an efficient and beautiful pagination function, greatly enhancing the user experience and management efficiency of the website.


Frequently Asked Questions (FAQ)

1. Why is the pagination link not displayed in my article or Tag document list?

This is usually due to not callingarchiveListortagDataListthe tag correctlytypethe parameter to"page", or not properly introducing it in the templatepaginationTags to render pagination navigation. Make sure your tag calls includetype="page", and add{% pagination pages with show="5" %}...{% endpagination %}such code to display pagination links.

How to customize the style and layout of pagination links?

AnQiCMS'paginationThe tag is responsible for providing pagination data and generating the corresponding URL, it does not generate any built-in CSS styles. You can customize it as needed,{% pagination pages with show="5" %}...{% endpagination %}Within the tag, use HTML and CSS to completely customize the pagination style and layout. For example, you can wrap each page number link in<li>In the tag, then beautify it with CSS, or use flexbox layout to control the arrangement of pagination buttons.

3. Where else can the pagination feature of AnQiCMS be used, besides articles and Tag lists?

The design philosophy of AnQiCMS is universal, so in addition to the article and Tag document lists, similar pagination mechanisms can also be applied to other places that require list display and may contain more content. For example, the comment list (commentListTags are also supportedtype="page"Parameters can be used withpaginationTags can be used to implement pagination of comment content to avoid the page being too long due to too many comments on a single article page.

Related articles

How to display the friend link list at the bottom of the AnQiCMS website?

In website operation, friendship links play an indispensable role.It is not only an effective way for websites to recommend and share traffic with each other, but also an important means to enhance the weight and visibility of websites in search engines.However, how to conveniently manage and display these links on a website is a practical problem faced by many website managers.AnQiCMS as a system focusing on enterprise-level content management and SEO optimization, provides an intuitive link function and a flexible template calling mechanism, making this process extremely simple.###

2025-11-08

How does AnQiCMS display the website message form and customize the form field display?

AnQi CMS: Flexible display and field customization of the website message form In website operation, the message form is an important bridge connecting users and the website.Whether it is to collect customer feedback, provide consulting services, or interact with users, a well-functioning and easy-to-use comment form is particularly important.AnQiCMS (AnQiCMS) is well-versed in this field, providing users with a powerful and flexible feedback form feature, which can be easily displayed on the website front-end and supports in-depth customization of form fields to meet various business needs.### One,

2025-11-08

How to display the Tag list of articles and detailed information of a single Tag as well as associated documents in AnQiCMS?

How to effectively organize and display content in a content management system is the key to improving user experience and search engine friendliness.AnQiCMS provides a powerful Tag feature, helping us to classify and display content more finely.This article will provide a detailed introduction on how to flexibly use tags in AnQiCMS, including displaying tag lists, viewing detailed information of individual tags, and listing documents associated with specific tags.The role of tags in AnQiCMS Tags are a flexible content organization method in AnQiCMS

2025-11-08

How does AnQiCMS's 'Document Parameter Filtering' feature help users perform combined filtering of content lists on the front end?

Today, with the rich content of websites, how to help visitors quickly and accurately find the information they are interested in has become a key challenge in content operation.Imagine if your website had thousands of articles, products, or cases, and visitors could only filter through them with simple categorization and search, it would undoubtedly greatly reduce their exploration efficiency and satisfaction.AnQiCMS is well-versed in this field and has provided us with a highly efficient and flexible solution - the "document parameter filtering" feature.This feature is like an intelligent guide, able to meet various conditions we preset

2025-11-08

How to use if/for tags in a template to control the conditional display and looping display of content?

When building and operating a website, the dynamic display and flexible management of content are key to improving user experience and operational efficiency.AnQiCMS (AnQiCMS) understands this point, therefore its template engine provides powerful and intuitive conditional judgment (`if`) and loop traversal (`for`) tags, allowing you to easily control the display logic of content and achieve highly customized page layouts.The template syntax of AnQi CMS borrows the concise style of Django template engine, with a very low learning cost.By mastering these core tags

2025-11-08

How to format a timestamp into a readable date and time format for display in AnQiCMS?

The website content is updated frequently, each article, product, or comment has its creation and update time point.However, these times are usually stored in the background in the form of a series of numbers, which is what we commonly call timestamps.It is not friendly to display these timestamps to visitors, we need to convert them into a clear date and time format.In AnQiCMS, formatting these timestamps into the date and time format we are accustomed to is actually very simple and intuitive.The system comes with a powerful template tag that can help us easily achieve this.###

2025-11-08

How to define temporary variables in templates to assist in content display logic?

When using AnQiCMS for website content management, the flexibility of the template is crucial for achieving diverse content display.At times, we need not only to output data directly, but also to perform some temporary processing, calculation, or judgment based on business logic, at which point defining temporary variables in the template becomes particularly useful.This not only makes the template code more tidy, but also avoids repeated retrieval or calculation of the same data, thereby improving rendering efficiency and maintainability.The template engine syntax of AnQi CMS is similar to Django template engine

2025-11-08

How to reference the common template code snippets (such as header and footer) in AnQiCMS to unify the display of the page?

It is crucial to maintain a unified page style in website content operation to enhance user experience and maintenance efficiency.Imagine if your website had hundreds or even thousands of pages, and each page's header, footer, or sidebar needed to be manually modified, that would be an enormous project.Fortunately, AnQiCMS provides a powerful and flexible template mechanism that can help you easily refer to and manage common code snippets, ensuring the consistency of the website display.AnQiCMS's template system borrows the syntax of the Django template engine, making it easy to use and powerful.it passes `

2025-11-08