How to handle the pagination problem when nesting `archiveList` inside `categoryList`?

Calendar 👁️ 55

As an experienced website operations expert, I have accumulated rich experience in the content management practice of AnQiCMS.I am well aware that when facing the powerful template tag system of AnQiCMS, how to skillfully combine them to achieve the expected content display effect is a challenge that many operators and developers may encounter.categoryListnestedarchiveListhow to properly handlearchiveListpagination problem?

pagination困境:understanding the core logic in nested scenarios

First, let's clarify what AnQiCMS is aboutcategoryListandarchiveListThe function of these two core tags.categoryListTags are used to iterate over and display the classification information of the website, such as listing all product categories on the homepage, or displaying the article classification tree in the sidebar. AndarchiveListTags are used to retrieve and display a list of documents (articles, products, etc.). When we need to display related documents under a category, it is natural to nestarchiveListincategoryListthe loop.

Where are the challenges of pagination? In AnQiCMSarchiveListTags can be set bytype="page"Parameters to enable pagination and work withpaginationCreate pagination links. However, the key here is that the pagination parameters in the URL (such as?page=2) are usually targetedat the single list of the main content area of the entire pagefor control.

Imagine if you displayed multiple categories on a page, each with onearchiveListto display their articles. At this point, if eacharchiveListTry to perform "pagination", in the URL of?page=XWhat parameter should control which category of document list jumps to the second page?This is contradictory and cannot be unified in logic.A page usually only has one leading pagination list.

Therefore, when you try tocategoryListLoop to set each nestedarchiveListAll to settype="page"And when you expect them to be independently paginated, you will find that this method cannot achieve the effect you might imagine of 'each category has its own independent pagination control'.

Solution one: Display in nested scenarios in a 'summary-style'

In most cases, it willarchiveListincategoryListIn order to display on the homepage, category overview page, or sidebar, etc., in order tosummary or selectedDisplay a few of the latest or most popular documents in each category.Under such 'summary' display scenarios, we usually do not need to provide complete pagination functionality for each category of document list.

The correct approach is to let nestedarchiveListUsetype="list"parameters cooperatelimitto limit the number of documents displayed. In this way, each category will show its latest few articles without the inconvenience of pagination.

For example, suppose you want to display several main categories on the homepage, with the latest 5 articles displayed under each category:

{% categoryList categories with moduleId="1" parentId="0" %}
<div class="category-sections">
    {% for category in categories %}
    <div class="category-card">
        <h3><a href="{{ category.Link }}">{{ category.Title }}</a></h3>
        <ul>
            {# 在分类列表内部,我们通常只展示每个分类的最新几篇文章,而不是分页显示所有文章 #}
            {% archiveList archives with type="list" categoryId=category.Id limit="5" order="id desc" %}
            {% for article in archives %}
            <li>
                <a href="{{ article.Link }}">{{ article.Title }}</a>
                <span class="publish-date">{{ stampToDate(article.CreatedTime, "2006-01-02") }}</span>
            </li>
            {% empty %}
            <li>该分类暂无文章。</li>
            {% endfor %}
            {% endarchiveList %}
            <a href="{{ category.Link }}" class="more-link">查看更多 {{ category.Title }} 的文章 &raquo;</a>
        </ul>
    </div>
    {% endfor %}
</div>
{% endcategoryList %}

In this code block,archiveListExplicitly usedtype="list"andlimit="5"Ensure that each category only displays a fixed number of documents. If a user wants to view all the documents in a category and browse them by pages, they will click on the category title or the "View More" link and jump to the category'sExclusive List Page.

Solution Two: Full-page pagination of the exclusive list page

When the user clicks to enter a specific category page (for exampleyourdomain.com/category/newsThis page is the exclusive list page of this category. On this page, full-page pagination of documents is logical and meets user expectations.

In the template of the exclusive list page (usually{模型table}/list.htmlor{模型table}/list-{分类id}.html), you can usearchiveListtags and settype="page", along withpaginationTag to generate pagination. AnQiCMS is very intelligent, it will automatically identify the current category ID according to the current page URL, so you usually do not need to explicitly specify inarchiveListto specifycategoryId.

This is a dedicated list page template example:

"twig {# Assume this is a dedicated list page template for a category, such as article/list.html or article/list-123.html #} {% categoryDetail currentCategory %} {# Get the detailed information of the current category #}

List of articles of {{ currentCategory.Title }}

{% archiveList articles with type=“page” limit=“10” %} {# categoryId will automatically be obtained from the current page #}

{% for article in articles %}
<div class="article-item">
    <h3><a href="{{ article.Link }}">{{ article.Title }}</a></h3>
    <p class="description">{{ article.Description }}</p>
    <span class="meta-info">发布日期: {{ stampToDate(article.CreatedTime, "2006-01-02") }} | 浏览量: {{ article.Views }}</span>
</div>
{% empty %}
<p>该分类下暂无文章。</p>
{% endfor %}

{% endarchiveList %}

{# Pagination Control #} {% pagination pages with show=“5” %}

<nav class="pagination-controls">
    {% if pages.FirstPage %}
        <a href="{{ pages.FirstPage.Link }}" class="page-link">首页</a>
    {% endif %}
    {% if pages.PrevPage %}
        <a href="{{ pages.PrevPage.Link }}" class="page-link">上一页</a>
    {% endif %}

Related articles

Is the HTML structure generated by `categoryList` friendly to search engine crawlers, and how can it be optimized?

As an experienced website operations expert, I know that every detail can affect the performance of a website in search engines.Today, let's delve deeply into the `categoryList` tag generated by AnQiCMS, the degree of friendliness of its HTML structure to search engine spiders, and how we can cleverly optimize it to improve the website's SEO performance.Since its inception, AnQi CMS has been favored by operators for its SEO-friendly design concept.

2025-11-06

How to extend the additional features of the `categoryList` tag without modifying the AnQiCMS core code?

As an experienced website operations expert, I fully understand how to skillfully utilize the existing functions of the CMS system to expand without touching the core code, which is crucial for maintaining system stability and reducing upgrade costs.AnQiCMS (AnQiCMS) offers us a powerful tool for deep customization at the content operation level with its flexible template engine and rich tag system, among which the `categoryList` tag is often a point where we need to expand the function.In Anqi CMS

2025-11-06

Does the `categoryList` tag support fuzzy search or filtering by category name (without going through URL parameters)?

As an experienced website operation expert, with a deep understanding of the various functions and content operation strategies of AnQiCMS, I am more than happy to analyze whether the `categoryList` tag in AnQiCMS supports fuzzy search or filtering based on category names, an important issue.In the Anqi CMS template system, the `categoryList` tag is the core tool for developers and content operators to obtain and display the website category list.It helps us build clear website navigation and content structure with its concise and efficient characteristics. However,

2025-11-06

In AnQiCMS, `categoryList` and `pageList` coexist without any issues, a practical template for intelligent operation

As an experienced website operations expert, I know that the flexible use of template tags in a content management system is the key to building an efficient and multifunctional website.Many AnQiCMS (AnQiCMS) users, especially those friends who are new to template development, may have a question: Will there be a conflict if tags with different functions like `categoryList` and `pageList` are used simultaneously on the same page??

2025-11-06

`categoryList` returns the category data whether it includes user group or permission-related setting information?

In the daily operation and template development of AnQi CMS, we often need to obtain site data from different angles, and the category list (`categoryList`) is undoubtedly one of the most commonly used tags.However, regarding whether the `categoryList` returned classification data includes user group or permission-related setting information?This topic, we delve into the design philosophy and functional implementation of AnqiCMS, revealing the logic behind it.

2025-11-06

How to truncate long category names in the `categoryList` loop and add an ellipsis?

## Enterprise CMS Template Tips: Gracefully truncate long category names and add ellipsis In website operation, the display of category names may seem trivial, but it actually has a significant impact on user experience and page aesthetics.A well-designed website ensures that all its elements can coexist harmoniously, especially the navigation and text in the list.When the category name is too long, it may cause layout confusion, text overflow, and even poor display on different devices, seriously affecting the user's reading experience

2025-11-06

How to use the AnQiCMS `commentList` tag to display comments on the frontend page?

As an experienced website operations expert, I know that an active website cannot do without user interaction, and the comment feature is an important embodiment of user participation.In AnQiCMS (AnQiCMS), integrating and displaying comments is not difficult.Today, let's delve deep into how to use the powerful `commentList` tag of AnQiCMS to elegantly present comment content on your website's frontend page, thereby enhancing user engagement and content vitality.

2025-11-06

In AnQiCMS, how can the `commentList` tag implement pagination for comment data?

As an experienced website operations expert, I am well aware that the comment function in a content management system not only increases user interaction but also brings vitality and richness to the website.AnQiCMS (AnQiCMS) is an efficient content management system developed based on the Go language, which provides strong comment functions while also considering the flexibility of template creation.Today, let's delve into how to elegantly implement pagination of comment data using the `commentList` tag in AnQiCMS.--- ### AnQiCMS in English

2025-11-06