How does the `archiveList` tag display the article list based on categories, recommended attributes, or custom sorting?

Calendar 👁️ 69

In the AnQi CMS template system,archiveListTags are the core tool for building dynamic content lists. Whether it is a list of blog articles, a product display page, or a news information module,archiveListCan help you accurately filter, sort, and present content according to diverse needs, making your website content area come alive.

archiveListFundamentals: Understanding how it works.

UsearchiveListWhen labeling, you first need to define a variable to receive the article data you get, for examplearchives. Then throughforLoop through this variable, display the detailed information of each article. The basic structure is usually like this:

{% archiveList archives with type="list" limit="10" %}
    {% for item in archives %}
        <!-- 在这里展示每篇文章的信息,例如标题、链接、简介等 -->
        <a href="{{item.Link}}">{{item.Title}}</a>
        <p>{{item.Description}}</p>
    {% empty %}
        <!-- 如果没有找到文章,将显示这里的内容 -->
        <p>暂时没有相关内容。</p>
    {% endfor %}
{% endarchiveList %}

here,type="list"Means we want to get a normal list,limit="10"The number of displayed articles is limited.{% empty %}Tags are a very practical feature. When the list is empty, you can elegantly display a prompt message instead of leaving the page blank.

Precise positioning: Filter articles based on categories

In many scenarios, we may need to display articles under specific categories, such as 'Company News' or 'Industry Dynamics'.archiveListTag throughmoduleIdandcategoryIdThe parameter can very conveniently meet this requirement.

first, moduleIdThe parameter is used to specify the type of content model you want to obtain, such as the article model (usually)moduleId="1") or product model (usually)moduleId="2"This is the foundation, ensure you are operating under the correct model.

Then,categoryIdThe parameter allows you to specify one or more category IDs. If you want to get the ID of5articles under the category, you can set it like this:

{% archiveList archives with moduleId="1" categoryId="5" limit="10" %}
    <!-- 展示文章列表 -->
{% endarchiveList %}

If you want to get articles from multiple categories at the same time, for example, with ID:5and8categories, just separate them with commas:categoryId="5,8".

Moreover, if you want to display only the articles of the current category and not include the content of its subcategories, you can usechild="false"parameters:

{% archiveList archives with moduleId="1" categoryId="5" child="false" limit="10" %}
    <!-- 仅显示ID为5的分类下的文章,不包含子分类文章 -->
{% endarchiveList %}

By combining these parameters, you can flexibly control the source of the articles.

Highlight the key points: Use recommended attributes to display specific content

The AnQi CMS backend allows you to set various recommended properties for articles, such as 'Top [h]', 'Recommended [c]', 'Slideshow [f]', and so on.These properties are very useful in website operations and can help highlight important content in specific areas.archiveListTag throughflagParameters, can easily filter out articles with these attributes.

For example, to display 'Recommended' articles in a module on the homepage, you can use it like thisflag="c":

{% archiveList archives with moduleId="1" flag="c" limit="5" %}
    <!-- 展示5篇推荐文章 -->
{% endarchiveList %}

If you want to display the recommended attribute tags of articles in the article list at the same time, for example, displaying an icon such as "recommended" or "headline", you canarchiveListSet in the labelshowFlag="true". Thenforgo through the loop inside{{item.Flag}}Get the recommended attribute code for the article and process the style or icon accordingly.

{% archiveList archives with moduleId="1" showFlag="true" limit="5" %}
    {% for item in archives %}
        <h3>
            <a href="{{item.Link}}">{{item.Title}}</a>
            {% if item.Flag == 'h' %}<span class="flag-headline">头条</span>{% endif %}
            {% if item.Flag == 'c' %}<span class="flag-recommend">推荐</span>{% endif %}
        </h3>
    {% endfor %}
{% endarchiveList %}

This article with the 'headline' or 'recommended' attribute can be prominently displayed on the page.

Orderly: Implementing custom sorting of articles

The way articles are sorted directly affects the reading experience of users.archiveListTags provide a variety oforderparameter values, allowing you to adjust the order of articles according to your actual needs.

The most commonly used sorting methods include:

  • id desc: Sorted in descending order by article ID, which usually means the most recent articles are at the top.
  • views descThe articles are usually displayed in descending order of view count, showing the most popular articles.
  • sort desc: Sort in descending order by the "display order" field defined in the background. This means you can manually adjust the order of articles in the background, which is very suitable for manual management of recommended content.

For example, if you want to display the latest articles in a certain area and limit the number to 8, you can write it like this:

{% archiveList archives with moduleId="1" order="id desc" limit="8" %}
    <!-- 展示8篇最新文章 -->
{% endarchiveList %}

In order to display the most popular articles on the website, you can sort by page views:

{% archiveList archives with moduleId="1" order="views desc" limit="10" %}
    <!-- 展示10篇最热门文章 -->
{% endarchiveList %}

Integrate knowledge: Use multiple conditions in combination

archiveListThe true strength of the tag lies in its flexible parameter combination. You can use it simultaneously tomoduleId/categoryId/flagandorderbuild a very precise list of articles.

For example, to get the ID of5In the category, the top 10 articles with the 'recommended' attribute, sorted by views in descending order:

{% archiveList archives with moduleId="1" categoryId="5" flag="c" order="views desc" limit="10" %}
    <!-- 展示特定分类下推荐且热门的文章 -->
    {% for item in archives %}
        <h4><a href="{{item.Link}}">{{item.Title}}</a></h4>
        <p>浏览量: {{item.Views}}</p>
    {% endfor %}
{% endarchiveList %}

You can also useexcludeCategoryIdandexcludeFlagParameters to exclude specific categories or recommended attributes, further refining your content filtering.

###

Related articles

How are the `pageList` and `pageDetail` tags used to display single-page content such as 'About Us'?

In website operation, content such as 'About Us', 'Contact Information', or 'Service Introduction' usually exists as independent pages, which we call 'single pages'.They do not update as frequently as blog posts, but they are essential core information for the website.AnQi CMS provides the `pageList` and `pageDetail` tags, allowing you to manage and display these single-page contents flexibly and efficiently.

2025-11-08

How to retrieve and display the name, description, and thumbnail of a specific category?

In website operations, clearly and effectively displaying classification information is crucial for user experience and search engine optimization.A specific category name can help users quickly understand the content theme, a concise description can provide more background information, and a direct thumbnail can attract users to click.AnQiCMS (AnQiCMS) provides a powerful and flexible template tag feature, allowing you to easily obtain and present these key classification information, whether it is to build a navigation menu, design a category list page, or optimize search engine results.###

2025-11-08

How to use the `categoryList` tag to display the list of articles/products categories on the homepage or sidebar?

When building and optimizing a website, a clear navigation structure is crucial for user experience and search engine optimization.AnQiCMS (AnQiCMS) provides us with powerful template tags, among which the `categoryList` tag is a core tool used to flexibly display article or product category lists on the homepage or sidebar of the website.With it, we can easily organize the content of the website neatly, allowing visitors to find the information they are interested in at a glance.Why is the category list so important? Imagine when visitors come to a rich content website

2025-11-08

How to automatically generate breadcrumb navigation using the `breadcrumb` tag and customize the display text on the homepage?

The user experience of a website largely depends on the convenience and clarity of navigation.When the visitor delves into the website content, a friendly 'Breadcrumb Navigation' can clearly indicate the current position and provide a quick path to return to the upper page.AnQiCMS is well-versed in this, providing a powerful and easy-to-use `breadcrumb` tag that allows website administrators to automatically generate paths without complex coding, and even to flexibly customize the display text on the homepage.

2025-11-08

How to display article title, content, images, etc. on the document detail page using the `archiveDetail` tag?

Manage website content in Anqi CMS, the document detail page is undoubtedly the core position for users to obtain information.How to present each carefully written article, its title, content, images, and various additional information accurately and vividly to the user, this requires the clever use of our `archiveDetail` tag.This tag is specifically designed to display the details of a single document, and its flexible use will help you easily build a feature-rich and smooth experience detail page.

2025-11-08

How to implement the previous/next document function using `prevArchive` and `nextArchive` tags?

When you operate a website, providing a smooth reading experience for users is one of the key factors in enhancing website stickiness.When a user finishes reading a document, if they can easily jump to the previous or next related article, it will undoubtedly greatly increase their stay time on your website.AnQiCMS (AnQiCMS) understands this and provides very intuitive and powerful `prevArchive` and `nextArchive` tags to help you easily implement this feature.

2025-11-08

How to use the `archiveList` tag's `type="related"` feature to display related article recommendations?

On your website, when visitors finish reading an article, if they can see related content in time, it not only can significantly improve the user experience, reduce the bounce rate, but also can effectively increase the page views and stay time on the website.AnQi CMS provides a very convenient tag: `archiveList`,配合其`type="related"` attribute, it can easily realize this function.###

2025-11-08

How does the `archiveParams` tag display custom field data of the document on the frontend page?

In AnQi CMS, the flexibility of content is one of our core advantages for website operation and content management.In addition to standardized fields such as titles and text, we often need to add specific custom information for different types of content, such as the 'brand', 'model', and 'origin' of products, or the 'author' and 'source' of articles, etc.These custom fields greatly enrich the dimensions of content display, but how to accurately and flexibly present these meticulously entered backend data on the front-end page is an important consideration during template development. At this time

2025-11-08