How to control the number of articles displayed per page and the sorting method on the article list page?

Calendar 👁️ 75

Fine control: The practical guide to the number and sorting of the article list page of AnQi CMS

In content operation, the article list page of the website is an important window for users to browse content and discover information.A well-organized and content-ordered list page, which not only improves user experience but is also a key aspect of search engine optimization (SEO).Anqi CMS is well-versed in this, allowing you to easily and finely control the number of articles displayed per page and the sorting method of the content through its powerful and flexible template tag system.

This article will guide you in-depth on how to use the core template tags in AnQi CMS to achieve this goal, making your website content more attractive and logical.

The core tag reveals:archiveListIts powerful functions

In AnQi CMS, the call of all articles, products and other content data is inseparable from a core tag:archiveList. It is like your dedicated content manager, able to accurately filter and present the required articles according to your instructions.The core that controls the number of items displayed per page and the sorting method, and it is also achieved through different parameters of this tag.

Master the quantity:limitParameters and flexible pagination

To control how many articles are displayed per page on the list page,archiveListlabel'slimitis your preferred tool parameter.

If your list page does not require pagination and you just want to simply display a fixed number of articles, such as the 'Latest Articles' module on the homepage, you cantypethe parameter tolist,and cooperatelimitThe parameter specifies the number of items to display. For example, if you want to display the latest 5 articles:

{% archiveList archives with type="list" limit="5" %}
    {% for item in archives %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
    {% endfor %}
{% endarchiveList %}

For articles list pages that require pagination, such as all articles in a category, you need to settypethe parameter topage. At this point,limitThe parameter's role has become to define the 'number of articles displayed per page'. In order for the page to display the complete page number navigation, we need to introducepaginationTags:

{% archiveList archives with type="page" limit="10" %} {# 每页显示10篇文章 #}
    {% for item in archives %}
        <li>
            <a href="{{item.Link}}">
                <h5>{{item.Title}}</h5>
                <p>{{item.Description}}</p>
                <span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>浏览量:{{item.Views}}</span>
            </a>
        </li>
    {% endfor %}
{% endarchiveList %}

{# 分页导航 #}
<div class="pagination">
    {% pagination pages with show="5" %} {# 最多显示5个页码按钮 #}
        <ul>
            <li class="{% if pages.FirstPage.IsCurrent %}active{% endif %}"><a href="{{pages.FirstPage.Link}}">首页</a></li>
            {% if pages.PrevPage %}
                <li><a href="{{pages.PrevPage.Link}}">上一页</a></li>
            {% endif %}
            {% for item in pages.Pages %}
                <li class="{% if item.IsCurrent %}active{% endif %}"><a href="{{item.Link}}">{{item.Name}}</a></li>
            {% endfor %}
            {% if pages.NextPage %}
                <li><a href="{{pages.NextPage.Link}}">下一页</a></li>
            {% endif %}
            <li class="{% if pages.LastPage.IsCurrent %}active{% endif %}"><a href="{{pages.LastPage.Link}}">尾页</a></li>
        </ul>
    {% endpagination %}
</div>

In this code block,archiveListBylimit="10"Tell the system to display 10 articles per page, andpaginationTags are responsible for generating navigation links such as 'Home', 'Previous Page', '1, 2, 3...', 'Next Page', 'End Page' based on the current page number and total number of articles, allowing users to freely switch between different pages.show="5"The parameter controls the maximum display quantity of the middle page number button.

Define order:orderMultiple parameter options

The way articles are sorted directly affects the presentation logic of the content and the reading habits of users. Anqi CMS'sarchiveListtags provide flexibleorderParameters, allowing you to sort articles according to different logic based on your actual needs.

Common sorting methods include:

  • Latest release:This is usually the default sorting method of the website, articles are sorted byid descDisplay in reverse order by ID, i.e., in reverse chronological order, with the most recently published articles at the top.
  • Hot articles:Sorted based on the number of article viewsviewsFor example,order="views desc"The article with the highest view count will be displayed first.
  • Custom sorting in the background:If you wish to manually adjust the order of the articles, you can set a "display order" value while editing the articles in the background, then useorder="sort desc"Call it. The smaller the number, the earlier it is usually (depending on the backend settings).
  • Mixed sorting:You can also combine multiple sorting rules, for exampleorder="flag desc|views desc"It will first be sorted by recommended attribute (flag), and then sorted by views in case of the same recommended attribute.

The following is an example of an article list sorted by views in descending order:

{% archiveList hotArchives with type="list" limit="8" order="views desc" %} {# 获取浏览量最高的8篇文章 #}
    <h3>热门文章</h3>
    <ul>
        {% for item in hotArchives %}
            <li><a href="{{item.Link}}">{{item.Title}} - {{item.Views}}次浏览</a></li>
        {% endfor %}
    </ul>
{% endarchiveList %}

Comprehensive application: making content display more accurate

exceptlimitandorderparameter,archiveListTags support multiple filtering conditions, allowing you to more accurately control the content displayed on the list page:

  • categoryId:Specify the category ID of the article. For example:categoryId="1"Only display articles under the category with ID 1.
  • moduleId:Specify the model ID of the article. For examplemoduleId="1"Only display the content under the "Article Model", whilemoduleId="2"then display the content under the "Product Model".
  • flag:Filter according to the recommended attributes of the article (such as “Top[h]”, “Recommended[c]”, etc.). For exampleflag="h"Only display articles marked as Top.”
  • q:In the search results page, throughqThe parameter can match the content of the article title that includes specific keywords.

By flexibly combining these parameters, you can build various complex and logical article list pages, whether it is by category, by tag, or combined with popular, recommended, and other attributes, it can be realized in Anqi CMS.

Practice case: Step-by-step configuration of the list page

  1. Confirm the template file:First, find the template file corresponding to the list page you want to modify. Usually, the naming convention of the template for the article category list page might be{模型table}/list.htmlor{模型table}/list-{分类ID}.html.
  2. WritingarchiveListTags:In the template, usearchiveListTag to retrieve article data and set according to requirementstypeWithpageandlimitParameters to define the number of items per page

Related articles

How to customize the URL rewrite rules for the article detail page in the AnQiCMS template?

## Optimize SEO, Enhance User Experience: AnQiCMS Detailed Explanation of Custom Article Detail Page URL Static Rules In website operation, a clear and meaningful URL structure is crucial for search engine optimization (SEO) and user experience.Imagine a user sees `/article.php?Which link would be more attractive to them, the one with `id=123&category=news` such as this, or the one with `/news/anqicms-url-guide.html` such as this?

2025-11-07

How to customize the display of SEO titles, keywords, and descriptions on the AnQiCMS homepage?

In the digital age, the homepage of a website is like the 'front door' of a company, the information presented to search engines is crucial.An meticulously optimized homepage that clearly conveys the core value of the website, attracts target users, and provides friendly crawling signals to search engines.In AnQiCMS, customizing the display of the SEO title (Title), keywords (Keywords), and description (Description) on the homepage is a straightforward and powerful process, which is an important manifestation of AnQiCMS's SEO-friendly features.

2025-11-07

How does AnQiCMS adaptively display website content for different devices (PC/Mobile end)?

In today's parallel network environment of multiple devices, users may access websites through desktop computers, laptops, tablets, or smartphones.Therefore, ensuring that the website content displays well on different devices and provides a smooth user experience is a key link in the success of website operation.AnQiCMS as an enterprise-level content management system fully considers this requirement and provides a flexible and diverse adaptive display scheme for device content, allowing users to choose the most suitable method according to their own situation.AnQiCMS mainly provides three core strategies for handling multi-device display of website content

2025-11-07

How does the `thumb` filter quickly generate and display a thumbnail version of the original image URL?

In website operation, images are key elements to attract users and enrich content, but large image files often slow down page loading speed, affecting user experience and search engine optimization.Anqi CMS knows this and therefore provides a very convenient and efficient solution——the `thumb` filter.It can easily convert the original image into a thumbnail version suitable for web display, without manual processing, greatly enhancing the efficiency of content publication and the overall performance of the website.### Core Function Analysis: `thumb` Filter's Working Principle This is named

2025-11-07

How to implement the multi-language content switching and front-end display of AnQiCMS website?

It is undoubtedly a crucial link in the construction of a global digital content platform.AnQiCMS (AnQiCMS) is a management system designed specifically for content operators, deeply understanding this field, providing comprehensive multi-language content switching and front-end display functions, aiming to help users efficiently expand into the international market and reach a wider audience.## AnQiCMS Multilingual Function Overview AnQiCMS is developed based on Go language, and it is an ideal choice for small and medium-sized enterprises and content operation teams due to its high efficiency, customizability, and scalability.

2025-11-07

Does AnQiCMS support directly retrieving and displaying system configuration information (such as website name, Logo) in templates?

During the process of building and maintaining a website, we often encounter the need to display basic information about the website at various positions on the page, such as the name of the website, Logo, copyright statement, filing number, and so on.If this information is scattered in all corners of the template, it will be very cumbersome and prone to errors once it needs to be modified.What kind of solution does AnQiCMS provide in this regard?Does it support us to directly obtain and display these system-level configuration information in the template?The answer is affirmative.

2025-11-07

How to call and display the contact information (phone, email, address) set in the back-end template on the front-end?

It is crucial to clearly and effectively display contact information in website operation to establish user trust and promote communication.Whether it is to consult products, seek service support, or give feedback, a reachable phone, email, or address can greatly enhance the user experience.AnQiCMS (AnQiCMS) fully considers this requirement, providing a flexible and convenient way for website administrators to centrally manage contact information in the background, and easily call and display on the front-end page through simple template tags.### Step 1

2025-11-07

How does AnQiCMS ensure the safety and compliance of front-end displayed content, such as sensitive word filtering?

When operating a website, the security and compliance of content is an indispensable part, especially in the context of the increasingly regulated online environment today.For users who use AnQiCMS, the system provides a variety of functions to help ensure the security and compliance of the displayed content on the front end, such as the sensitive word filtering that users are generally concerned about.At the beginning of its design, AnQiCMS placed content security at the core position.It is not just a content publishing tool, but also a platform dedicated to providing users with a safe and compliant content management environment

2025-11-07