How to combine `archiveList` with `pagination` tag to implement pagination navigation for document list?

Calendar 👁️ 49

As an experienced website operation expert, I am well aware of the importance of an efficient content management system (CMS) for website operation, and AnQiCMS (AnQiCMS) provides us with great convenience with its high concurrency characteristics of Go language and flexible template mechanism.Among many features, how to effectively display a large number of documents and provide friendly pagination navigation is crucial for improving user experience and content accessibility.Today, let's delve deeperarchiveListHow to combine tags withpaginationThe tags cleverly combine to implement the pagination navigation function of the document list.

In the AnQiCMS template system,archiveListTags are the core tools used to obtain the document list, andpaginationTags focus on generating beautiful and practical pagination navigation. They do not operate independently, but work together to form a complete document pagination display solution.Understanding the functionality and collaboration mechanism of these tags is the foundation for building high-performance, user-friendly websites.

archiveList: Build the core of the document list.

First, let's get to knowarchiveListThe label. It is mainly responsible for retrieving and outputting a collection of documents that meet specific conditions. When we want to add pagination to the document list,archiveListis a key parameter——typeIt is particularly important.

When we willarchiveListoftypethe parameter to"page"When, the AnQiCMS system will understand that we not only need to obtain the document data of the current page, but also need the system to provide all the metadata required for pagination, such as the total number of documents, total number of pages, current page number, etc. This metadata is exactlypaginationThe basic page navigation tag is generated.

excepttype="page"other than,archiveListIt also supports a rich set of parameters for precise control of document filtering and sorting, such as:

  • moduleId: Specify which content model document to retrieve (such as article model or product model).
  • categoryId: Specify which category or multiple categories of documents to retrieve.
  • limitDefine the number of documents displayed per page, which directly affects the pagination size.
  • orderControl the sorting method of documents, such as in reverse order by publication time (id desc) or in reverse order by views (views desc)

WhenarchiveListStart withtype="page"When the pattern runs, it will store the processed document data in a variable we specify (for examplearchives), and will also prepare the pagination metadata ready forpaginationTag calling.

pagination: Intelligent generation of pagination navigation

Immediately thereafter,paginationThe label makes its appearance. Its task is toarchiveListThe provided pagination metadata, intelligently generates home page, previous page, next page, last page, and a series of page number navigation links.The introduction of this tag greatly simplifies the complexity of building pagination logic for front-end developers.

paginationThe label usually receives a namedshowparameter to control the number of pages displayed in the navigation bar. For example,show="5"It means that a total of 5 page number links will be displayed before and after the current page to keep the navigation concise.

paginationThe tag will provide a variable (for example,pages), this variable contains all the information needed to build the pagination navigation:

  • pages.TotalItems: Total number of documents.
  • pages.TotalPages: Total number of pages.
  • pages.CurrentPage: Current page number.
  • pages.FirstPage/pages.LastPage/pages.PrevPage/pages.NextPage: Representing the links and names of the first page, last page, previous page, and next page.
  • pages.PagesThis is an array containing all visible page number information, each element of which hasName(page number),Link(Page link) andIsCurrent(whether it is the current page) and other attributes for easy loop rendering.

Actual operation: Strong cooperation to achieve pagination

Now, let's look at a specific code example to seearchiveListandpaginationHow it works together in the AnQiCMS template. Suppose we want to display a list of articles on a category page or a model home page and add pagination.

{# 首先,使用archiveList标签获取文档列表,注意设置type="page"以启用分页 #}
<div>
{% archiveList archives with type="page" limit="10" moduleId="1" categoryId="1" order="id desc" %}
    {# 遍历文档列表,并显示每篇文档的简要信息 #}
    {% for item in archives %}
    <article class="document-item">
        <a href="{{item.Link}}">
            <h2>{{item.Title}}</h2>
            <p>{{item.Description}}</p>
            <div class="meta-info">
                <span>分类:{% categoryDetail with name="Title" id=item.CategoryId %}</span>
                <span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>阅读量:{{item.Views}}</span>
            </div>
            {% if item.Thumb %}
            <figure class="document-thumb">
                <img alt="{{item.Title}}" src="{{item.Thumb}}">
            </figure>
            {% endif %}
        </a>
    </article>
    {% empty %}
    {# 当没有文档时显示的内容 #}
    <p class="no-content-tip">当前分类下暂无文档。</p>
    {% endfor %}
{% endarchiveList %}

    {# 接下来,使用pagination标签生成分页导航。它会自动使用archiveList提供的数据 #}
    <nav class="pagination-navigation">
        {% pagination pages with show="5" %}
            <ul>
                {# 首页链接 #}
                <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>
            <div class="pagination-info">
                <span>总计:{{pages.TotalItems}}条</span>
                <span>当前第:{{pages.CurrentPage}}/{{pages.TotalPages}}页</span>
            </div>
        {% endpagination %}
    </nav>
</div>

In the above code, we first obtained the article list througharchiveListtags and specifiedtype="page"and displayed per page10articles. Then, we used aforLoop througharchivesA variable that displays the title, summary, category, publish date, and reading volume of each article. If the list is empty,{% empty %}the prompt information in the block will be displayed.

Immediately thereafter,paginationthe tag receivedarchiveListProcessed pagination data, and using its internalpagesvariable to build the complete pagination navigation. We usepages.FirstPage/pages.PrevPage/pages.NextPage/pages.LastPageto create special page number links, and through{% for item in pages.Pages %}Loop dynamically generate the middle page number. In which,item.IsCurrentBoolean values can help us easily add the current page number.activeHighlight the class visually. Finally, we also displayed the total number of items and the current page/total pages information, further enriching the user experience.

Flexible customization and optimization: take it further

ThisarchiveListCombinepaginationPagination method, not only provides basic functions, but also leaves sufficient customization space.

In terms of style, we can customize according to the design language of our website, to.document-item/.pagination-navigation/.page-itemas well as.activeWait for CSS classes to write unique styles to create pagination components consistent with the overall style of the website.Due to the support of AnQiCMS template for Django template engine syntax, this means that we can make use of its powerful conditional judgment, loop control, and other functions to perform more complex logic processing on pagination navigation, such as simplifying pagination display on mobile devices or hiding certain pagination links in specific situations.

In terms of SEO, AnQiCMS built-in pseudo-static features ensure that the URL structure of pagination links is friendly and can be indexed by search engines, which is crucial for improving the overall SEO performance of the website.By implementing this standardized pagination, search engines can better understand and index the deep content of websites, avoiding duplicate content or indexing issues caused by pagination.

Summary: Make content management more efficient

ByarchiveListandpaginationThese tags work closely together, AnQiCMS provides us with a powerful and flexible document list pagination solution.It clearly separates complex backend data processing from the frontend page rendering logic, making content management and website frontend development more efficient and convenient.Whether it is to build a corporate website, content portal, or blog system, mastering this combination will help us better operate the website and provide users with

Related articles

How to display the Flag attribute of the document in the `archiveList` loop, for example, 'Recommended' or 'Bold'?

As an experienced website operations expert, I am happy to deeply analyze how to flexibly use the `archiveList` loop in AnQiCMS to display the Flag attribute of documents, such as "recommended" or "bold".The core of content operation lies in how to effectively distinguish and highlight key content, and the Flag attribute is a powerful and easy-to-use feature provided by AnQiCMS for this purpose.--- ### Light up your content

2025-11-06

How to get the thumbnail, description, and publish time of the document in the `archiveList` loop?

As an experienced website operations expert, I know that how to efficiently and flexibly display content in a content management system is one of the key factors for the success of a website.AnQiCMS (AnQi CMS) relies on its powerful template engine and simple tag design, making content display extremely convenient.Today, let's delve into a very practical scenario: how to elegantly obtain and display the thumbnail, description, and publication time of documents in the `archiveList` loop.

2025-11-06

How to call the document data of different sites (`siteId`) through the `archiveList` tag?

As an experienced website operations expert, I fully understand the challenges you may encounter when managing multi-site content.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful multi-site management capabilities.Today, let's delve into how to use the `archiveList` tag and its core parameter `siteId` to easily implement cross-site document data calls.

2025-11-06

How to retrieve related content of the current document using the `archiveList` tag's `type="related"` mode?

As an experienced website operations expert, I am very happy to delve deeply into the `archiveList` tag in AnQiCMS with the `type="related"` mode, which plays a crucial role in content operations and can effectively improve user experience and the website's SEO performance. --- ## In-depth Analysis of AnQiCMS's `archiveList` Tag: How to intelligently retrieve related content and enhance user experience In such an efficient and customizable content management system as AnQiCMS

2025-11-06

How to get the SEO title, keywords, and description of the current document and use it in the page Meta tags?

As an expert well-versed in website operations, I know the importance of SEO titles, keywords, and descriptions (usually referred to as TDK, Title, Description, Keywords) for a website to perform well in search engines.They are the information that users see first on the search results page, directly affecting the click-through rate, and are also a key signal for search engines to understand the content of the page.

2025-11-06

How does the `archiveDetail` tag in AnQiCMS control the Markdown rendering or lazy loading of document content?

As an experienced website operations expert, I know that in the increasingly fierce online environment, efficient content management and elegant presentation are crucial for the success of a website.AnQiCMS is a powerful and flexible content management system that provides us with great convenience with its template tag system.Today, let's delve deeply into a seemingly simple yet powerful tool: the `archiveDetail` tag of AnQiCMS, especially its mysteries in controlling the Markdown rendering and lazy loading of document content.

2025-11-06

How to get the custom model field content of the `archiveDetail` tag?

In the powerful and flexible AnQiCMS content management system, the content model plays a core role, allowing us to build various personalized content structures according to business needs.Whether it is articles, products, activities, or other custom information, we can define unique fields for them.How can you elegantly present these rich custom field contents on the front-end page, which has become the key to template development.

2025-11-06

How to create a document filtering interface with the `archiveFilters` tag?

AnQi CMS is an efficient and customizable enterprise-level content management system, dedicated to providing powerful and flexible content management tools for website operators.In daily operations, we often need to provide users with a diverse range of content filtering functions to help them quickly find the information they are interested in.At this time, the `archiveFilters` tag provided by AnQi CMS can fully display its capabilities, allowing us to easily build a multi-condition document filtering interface, greatly enhancing the user's content discovery experience.### Understand `archiveFilters`

2025-11-06