How to use the AnQiCMS document list tag to display content for specific categories or recommended attributes?

Calendar 👁️ 61

In AnQi CMS, efficiently managing and displaying website content is the key to improving user experience and website operation effectiveness. Whether you want to display the latest articles of a specific category on the homepage or highlight products with the "recommended" attribute, AnQi CMS provides the document list tag (archiveListThese are the core tools to meet these requirements. Its flexible parameter configuration allows us to accurately control content retrieval, transforming technical details into accessible operational strategies.

Understand the document list labelarchiveList

archiveListThe tag is a powerful function in the AnQiCMS template system used to retrieve and display a list of documents (including articles, products, and other content models).By carefully configuring its parameters, we can easily achieve various customized content display requirements.

This is the basic structure of the tag:

{% archiveList 变量名 with 参数 %}
    {% for item in 变量名 %}
        {# 在这里展示每个文档项的具体内容 #}
    {% empty %}
        {# 如果没有内容,这里可以显示提示信息 #}
    {% endfor %}
{% endarchiveList %}

Among them,变量名for examplearchives) is a name we specify for the document list we retrieve, for easy reference in loops.with 参数It is the key to defining content filtering and sorting rules.

Precise filtering: control the source and characteristics of content

To display specific categories or content with recommended attributes, we need to focus on it.archiveListSeveral core parameters of the tag:

  1. Specify the content model (moduleId)There may be various types of content on the website, such as articles, products, cases, etc. These are defined as different "content models" in AnQiCMS. ThroughmoduleIdParameters, we can clearly tell the system which content model document needs to be called. For example, if you want to get a list of articles, you can setmoduleId="1"If it is a product list, it may be set tomoduleId="2"(Specific)moduleIdYou can view it in the background "Content Model" management).

  2. Retrieve by category (categoryId)This is one of the most commonly used content filtering methods. If you want to display all articles under a specific category on a page, or show the latest news of a category on the homepage,categoryIdParameters can be put to good use. For example, you can specify the ID of a single category, such ascategoryId="5"; You can also specify multiple categories at the same time, separated by commas, such ascategoryId="5,8,12". It is worth noting that if yourarchiveListThe tag is placed on a category page, by default the system will try to read the current category ID. If you want to prevent this automatic reading behavior, you can explicitly setcategoryId="0".

  3. Display recommended attribute content (flag)AnQiCMS provides rich "recommended attributes" for document content, these attributes are like tags for content, used to mark the specificity of the content.For example, you can mark important articles as "Top News", and hot-selling products as "Recommended".头条[h]/推荐[c]/幻灯[f]/特荐[a]/滚动[s]/加粗[h]/图片[p]/跳转[j]. To display content with specific recommended attributes, just add the corresponding attribute letter after the parameter. For example,flag.flag="c"All content marked as "recommended" will be retrieved.

  4. Content sorting (order)The order of content display is also important.orderThe parameter allows you to sort content based on different criteria.

    • order="id desc":Sorted by document ID in descending order, usually used to display the latest released content.
    • order="views desc":Sorted by view count in descending order, suitable for displaying popular or highly关注的 content.
    • order="sort desc": Sort by the custom sorting value in descending order, this parameter is very useful if you have manually set the sorting for the document in the background.
  5. Limit the display quantity (limit)To avoid too much content on the page,limitThe parameter can control the number of documents displayed. For examplelimit="10"It will only display the latest 10 items. When pagination is needed,limitthe parameter is also used with the pagination label (pagination)配合使用。

Practical Application: Scenario Example

Let's see how to apply these parameters through several specific scenarios:

Scenario One: Display the latest 5 articles under the "Company News" category on the homepage

Assuming your 'Company News' category ID is10, the content model is1(Article model). To retrieve the latest 5 articles under this category, you can write the code like this:

<div class="news-section">
    <h3>公司新闻</h3>
    <ul>
        {% archiveList latestNews with moduleId="1" categoryId="10" order="id desc" limit="5" %}
            {% for item in latestNews %}
                <li>
                    <a href="{{ item.Link }}" title="{{ item.Title }}">
                        {{ item.Title }}
                    </a>
                    <span>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                </li>
            {% empty %}
                <li>暂无公司新闻。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

This code will find the latest 5 articles from the article model with category ID 10 and list their titles and publication dates.

Scenario two: Display 3 'Recommended' products in the sidebar of the product list page

Assuming the content model ID of the product is2. Do you want to display products tagged as 'Recommended' (flag="c")

<div class="recommended-products">
    <h4>推荐产品</h4>
    <ul>
        {% archiveList recommendedProds with moduleId="2" flag="c" limit="3" %}
            {% for item in recommendedProds %}
                <li>
                    <a href="{{ item.Link }}" title="{{ item.Title }}">
                        {% if item.Thumb %}<img src="{{ item.Thumb }}" alt="{{ item.Title }}"/>{% endif %}
                        <p>{{ item.Title }}</p>
                    </a>
                </li>
            {% empty %}
                <li>暂无推荐产品。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Here we go throughflag="c"Filter out recommended products and display their thumbnails and titles.

Scenario three: Display the top 3 articles with the highest views under a specific category.

If you want to display the most popular articles under this category on a special page, you can combinecategoryIdandorder="views desc":

<div class="top-articles">
    <h3>热门文章</h3>
    <ul>
        {% archiveList hotArticles with moduleId="1" categoryId="current" order="views desc" limit="3" %}
            {% for item in hotArticles %}
                <li>
                    <a href="{{ item.Link }}" title="{{ item.Title }}">
                        {{ item.Title }}
                    </a>
                    <span>浏览量:{{ item.Views }}</span>
                </li>
            {% empty %}
                <li>暂无热门文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

HerecategoryId="current"It is an assumption, representing the current category ID (it is usually automatically obtained on the category detail page). If it is not on the category detail page, you need to replace it with the specific category ID.

How to improve content operation effectiveness

  • Flexible use of recommendation attributes:The website is operational, content distribution and highlighting key points are crucial.The recommended attributes of AnQiCMS provide great flexibility, allowing you to adjust the priority of content at any time based on promotional activities, hot events, or content importance.
  • Optimize the structure of the content model:Combine with custom content model fields,archiveListLabels can retrieve more personalized data (such as product prices, author information, etc.), making content display richer and more accurate. ByarchiveParamsLabel, it can be further used to obtain these additional fields in the loop.
  • Rational planning of the classification system:Clear classification not only facilitates user search but also makescategoryIdThe application of parameters more intuitive and effective.
  • Balancing performance and experience: limitThe use of parameters can effectively control the amount of content loaded each time,配合分页(whentype="page"),to avoid the page being too long and slow to load, improving user experience.

Through proficiencyarchiveListAll kinds of parameter combinations of tags, you will be able to easily build a website with rich content, flexible layout, and in line with operation strategies under the empowerment of AnQiCMS, so that content can maximize its value.


Frequently Asked Questions (FAQ)

  1. Question:archiveListin the labelcategoryIdCan the parameter specify multiple categories? How can it be specified?Answer: Yes,categoryIdThe parameter can specify multiple categories. You just need to use English commas,Separate different category IDs, for examplecategoryId="1,5,8"Thus,archiveListThe tag will retrieve the content under these specified categories.

  2. How do I ask:archiveListIn the tag, how do I call the custom content model field (for example, article author or product price)?Answer:archiveListThe tag itself provides some standard fields (such asTitle/Link)。To call custom fields, you need to usearchiveListWithin a loop, for eachitemUsearchiveParamstags to retrieve. For example:

    {% archiveList archives with moduleId="1" limit="5" %}
        {% for item in archives %}
            <h3>{{ item.Title }}</h3>
            {% archiveParams params with id=item.Id %}
                {% for param in params %}
                    {% if param.FieldName == "author" %} {# 假设您自定义了一个字段名为 "author" #}
                        <p>作者: {{ param.Value }}</p>
                    {% endif %}
                {% endfor %}
            {% endarchiveParams %}
        {% endfor %}
    {% endarchiveList %}
    

    If you set the English call field when customizing the field (such asauthor), you can also try to use{{ item.author }}call, but througharchiveParamsloop traversal is more general.

  3. Ask: If I set the 'recommended' attribute (such as 'recommended[c]') for an article in the background, how can I display these recommended articles through thearchiveListtag on the front end?Answer: To display articles with specific "recommended" properties, you need to specifyarchiveListSet in the labelflagthe parameter. For example, to display all articles marked as "recommended[c]", you can write: {% archiveList recommendedArticles with moduleId="1" flag="c" limit="10" %}This allows you to filter and display content with the recommended attribute.

Related articles

How to display dynamic breadcrumb navigation in AnQiCMS and customize the home page name?

In website content management, breadcrumb navigation plays a crucial role.It not only helps visitors clearly understand their position on the website, provides a convenient path to return to the upper page, but also reflects the hierarchical structure of the website from the side, which is greatly beneficial to user experience and search engine optimization.AnQiCMS as a powerful content management system naturally provides a flexible way to manage and display this kind of navigation.

2025-11-08

How to integrate and display Markdown, mathematical formulas, and flowcharts correctly on the AnQiCMS page?

In AnQiCMS, adding Markdown, mathematical formulas, and flowcharts to content greatly enhances its expressiveness and readability, especially for technical documents, educational materials, or data analysis reports.AnQiCMS as an efficient content management system, provides flexible mechanisms to support these modern content display needs. To implement the correct display of Markdown, mathematical formulas, and flowcharts on the AnQiCMS page, it mainly involves enabling backend settings and the necessary introduction of frontend templates.Here are the detailed steps and some practical suggestions

2025-11-08

How does AnQiCMS ensure the display quality of image resources and perform automatic compression and WebP conversion?

In the era where content is king, the image resources on the website play a crucial role.They not only directly affect the beauty of the page, but are also key factors in determining the loading speed and user experience of the website.For operators, how to ensure the display quality of images while also taking into account the performance and storage costs of the website is undoubtedly a question worthy of reflection.AnQiCMS (AnQiCMS) is well-versed in this, providing a comprehensive image resource management and optimization strategy, aimed at helping users easily master this challenge.The foundation for ensuring the quality of image display

2025-11-08

How to use AnQiCMS filters to format and truncate output text content?

In the AnQiCMS content management system, the presentation effect of content often determines the user experience and the efficiency of information delivery.To meet the diverse content display needs, AnQiCMS provides a powerful and flexible template filter function.These filters can help us with fine-grained processing of the original text when displaying content, whether it's adjusting text style, optimizing display length, or performing data conversion, it can be easily achieved.

2025-11-08

How to implement the display of previous and next document links in AnQiCMS templates?

When browsing website content, users often want to be able to navigate easily between related articles.In order to find more information or simply enjoy a smooth reading experience, the "Previous" and "Next" document links play a crucial role.They can not only effectively increase the user's stay time on the website, reduce the bounce rate, but also have a positive impact on the internal link structure of the website and the search engine optimization (SEO), helping search engines better understand the relevance of the website content.### Core Function Analysis: AnQiCMS

2025-11-08

How to display custom field content on the AnQiCMS document detail page?

When managing website content in AnQiCMS, we often encounter the need to add some unique information for different types of documents (such as articles, products, etc.).AnQi CMS provides flexible content model features, allowing us to customize fields to meet these personalized needs.How can these custom fields be displayed on the document detail page of the website after they are created and filled with data? This is actually simpler than you imagine, AnQiCMS's powerful template tag system provides us with various convenient ways to achieve this.--- ###

2025-11-08

How to display the list of related documents in AnQiCMS, what is the logic?

How to effectively guide users to discover more interesting content in a content management system is the key to improving user experience and website depth.AnQiCMS handles the 'related document list' feature by providing a flexible and intelligent mechanism that allows us to easily display other articles or products closely related to the current content on the website. This not only helps to extend the user's stay on the website but also optimizes the search engine crawling efficiency through internal links.### AnQiCMS

2025-11-08

How to use AnQiCMS tags to display the document list under a specific Tag?

In AnQiCMS, tags are a powerful content organization method that helps us associate content with different categories and models more flexibly.Using labels appropriately can not only optimize the SEO performance of a website, but also significantly improve the user's experience in discovering content on the website.When we want to focus on displaying all relevant documents under a specific tag, AnQiCMS provides a set of intuitive and efficient template tags to meet this need.This article will introduce in detail how to use the built-in template tags of AnQiCMS

2025-11-08