How to use the `archiveList` tag to call the document list with specified categories and recommended attributes?

Calendar 👁️ 70

AnQi CMS is an efficient enterprise-level content management system, whose powerful content tags are the core of dynamic and personalized content display. For website operators, it is especially important to be proficient in using these tags, especiallyarchiveListCan greatly enhance the flexibility and efficiency of content management.

This article will elaborate on how to use.archiveListLabel, accurately call the document list with specified categories and recommended properties, helping you better build website pages that meet user needs and optimize content display.

archiveListTag: Core of dynamic content display.

In AnQi CMS,archiveListTags are a key tool for retrieving and displaying document lists from a database. Whether it's articles, products, or documents under other custom content models, as long as you want to present them in a list form,archiveListIt can be used for everything. It provides rich parameters, allowing you to finely control the filtering, sorting, and quantity of content, thus achieving a highly customized page layout.

Filter documents of specified categories

When building a website, we often need to display documents under specific categories on a single page.For example, display all news articles on the "News Center" page, or display a specific model of product on the "Products" page.archiveListTag throughcategoryIdThe parameter can easily meet this requirement.

You can use tocategoryIdAssign the parameter to specify the category ID to be called. If your category ID is1, the syntax iscategoryId="1"If you need to display documents from multiple categories at the same time, you can separate multiple category IDs with commas, for examplecategoryId="1,2,3".

In some cases, you may want toarchiveListAutomatically identify the category of the current page and display the documents under that category. In this case, it is usually unnecessary to omit.categoryIdParameter, the system will automatically try to obtain the category ID of the current page. However, if you want to explicitly not automatically obtain the current category ID, or call all category documents on a non-category page (such as the homepage), you can setcategoryId="0"Avoid system automatic reading.

In addition,archiveListwe also providechildThe parameter controls whether to include documents with subcategories. By default,childparameters fortrueThis means that when calling the parent category, all documents under its child categories will also be included in the list. If you only want to display the documents of the current category itself and do not want to involve any child categories, you canchildis set tofalse.

Call documents with recommended properties

The document publishing function of Anqi CMS allows content creators to set various recommended attributes for documents, such as headlines, recommendations, slides, etc.These properties are crucial in website content operation, and can be used to highlight important content, such as the focus image on the homepage, recommended articles in the sidebar, etc.archiveListTag throughflagParameters, allowing you to filter documents based on these recommended properties.

The system provides the following recommended properties:

  • Headline h
  • Recommended c
  • Slide f
  • Featured a
  • Scrolling s
  • Bold h(Note, this repeats the letter of the attribute of the headline, but usually a Flag letter represents an independent attribute)
  • Image p
  • Jump j

To call a document with a specific recommendation attribute, you just need to assign the corresponding attribute letter toflagthe parameter. For example, to display all documents marked as "recommended", you can set it like this:flag="c"If you want to display the "slideshow" content on the homepage, you can useflag="f"It should be noted that,flagParameters can only be specified once for filtering. If your website has multiple recommended attributes configured in the background, you can create multiple based on your actual needs.archiveListInvoke, each invocation filters a specific attribute.

Comprehensive application and code examples

In practice, we often need to combine classification and recommendation attributes to accurately locate content.For example, in the sidebar of a category page, you may want to display a list of recommended articles under that category.

{# 示例:在一个文章模型分类页面,显示当前分类下的“推荐”文章,限制显示5条 #}
{# archives 是您定义的变量名称,用于接收文档列表数据 #}
{% archiveList archives with type="list" categoryId="0" flag="c" limit="5" order="id desc" %}
    {% for item in archives %}
        <li>
            <a href="{{ item.Link }}" title="{{ item.Title }}">
                {% if item.Thumb %}
                    <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                {% endif %}
                <h3>{{ item.Title }}</h3>
                <p>{{ item.Description|truncatechars:80 }}</p>
                <span>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
            </a>
        </li>
    {% empty %}
        <li>当前分类下暂无推荐文章。</li>
    {% endfor %}
{% endarchiveList %}

In the above example:

  • type="list"Indicates that we want to get a simple list, not a paginated list.
  • categoryId="0"Make the tag automatically get the category ID of the current page (if it is a category page), or do not limit the category (if it is the homepage, etc.). If you know the exact category ID, you can directly replace it withcategoryId="具体分类ID".
  • flag="c"Specify only to obtain documents marked as "recommended".
  • limit="5"Limited the list to display only the latest 5 articles.
  • order="id desc"Documents are usually sorted in descending order by document ID, which means that the most recently published documents are at the top.

If your requirement is to display all 'headline' documents under all models and need to be displayed with pagination, you can write it like this:

{# 示例:显示所有内容模型下的“头条”文档,并进行分页 #}
{# archives 变量用于文档列表数据 #}
{% archiveList archives with type="page" flag="h" limit="10" order="views desc" %}
    {% for item in archives %}
        <div class="archive-item">
            <h2><a href="{{ item.Link }}">{{ item.Title }}</a></h2>
            <p>{{ item.Description }}</p>
            <span>浏览量:{{ item.Views }}</span>
            <span>更新时间:{{ stampToDate(item.UpdatedTime, "2006-01-02 15:04") }}</span>
        </div>
    {% empty %}
        <p>暂无头条文档。</p>
    {% endfor %}

    {# pages 变量用于分页信息 #}
    {% pagination pages with show="5" %}
        <div class="pagination-controls">
            {% if pages.PrevPage %}<a href="{{ pages.PrevPage.Link }}">上一页</a>{% endif %}
            {% for page_item in pages.Pages %}
                <a href="{{ page_item.Link }}" class="{% if page_item.IsCurrent %}active{% endif %}">{{ page_item.Name }}</a>
            {% endfor %}
            {% if pages.NextPage %}<a href="{{ pages.NextPage.Link }}">下一页</a>{% endif %}
        </div>
    {% endpagination %}
{% endarchiveList %}

In this example:

  • type="page"Means enabling pagination feature.
  • flag="h"Filter out all 'headline' documents.
  • limit="10"Set 10 documents to be displayed per page.
  • order="views desc"Sort documents by views from high to low.
  • Combined withpaginationUse tags to generate pagination links for easy browsing.

Summary

archiveListTags are an indispensable tool in the development of Anqi CMS templates. By using them flexibly,categoryIdandflagcombined with these two core parameters,type/limit/orderWith other parameters, you can easily implement various complex document list display requirements.This not only improves the organization efficiency of the website content, but also provides users with a more personalized and convenient browsing experience.


Frequently Asked Questions

how to be in aarchiveListFilter documents that have multiple recommendation properties at the same time (for example, both 'Headline' and 'Recommended')?

archiveListlabel'sflagThe parameter is designed to accept only one recommended attribute for filtering. This means you cannot directly pass through the samearchiveListtag withinflag="h,c"This method filters multiple properties simultaneously. If you need to display documents that meet multiple recommended properties, you usually need to implement custom program logic, such as adding a composite property in the background or performing multiple operationsarchiveListCall and merge on the front end (this is usually not recommended as it increases rendering complexity).The better approach is to ensure that the backend recommendation attributes can meet your single filter requirements, or design more detailed categories to distinguish content.

Why are there no Flag signs displayed on the front page, although my document list has already set the recommendation attribute?

archiveListTags are not included by default in the returned document dataFlagThe detailed information of the attribute. If you want toforget the recommended attributes of each document in the loop (for example,{{item.Flag}}), you need to explicitly setarchiveListthe tagsshowFlag=trueparameters. After setting,item.FlagIt will return the alphabetical combination of all recommended properties of the document, for examplehcMeans it is both a headline and a recommendation.

How can I set it so that only documents under the current category are displayed on the article list page, and not documents from any subcategoriesarchiveListTag?

archiveListlabel'schildThe parameter controls whether to include documents of subcategories. By default,childThe value istrueThis means that when you filter a category, all subcategories' documents will also be included in the list. If you want to strictly limit the display to the current category (i.e., the parent category itself) and exclude any subcategory documents, you should setchildthe parameter tofalseFor example:{% archiveList archives with categoryId="当前分类ID" child=false limit="10" %}.

Related articles

How to use the `archiveDetail` tag in AnQiCMS template to get document details and custom fields?

As an experienced CMS website operation personnel, I am well aware of the core position of content in website operations.We must not only create high-quality content, but also ensure that this content can be presented to users in a **way.In this, the flexible use of templates is crucial. Today, we will delve into a powerful and commonly used tag in AnQiCMS templates, `archiveDetail`, which helps us easily obtain detailed information about documents, including those carefully designed custom fields.###

2025-11-06

How to correctly display Markdown content, mathematical formulas, and flowcharts in AnQiCMS templates?

As an experienced AnQiCMS website operator, I know that it is crucial to display a diverse range of information efficiently and accurately in the increasingly rich online content ecosystem.Markdown is a lightweight markup language that is widely popular for its simplicity and efficiency.And mathematical formulas and flowcharts are essential expressions for conveying science, technology, or complex logic.This article will detail how to properly configure the AnQiCMS template to perfectly present these advanced contents.

2025-11-06

What are the pseudo-static rule modes supported by AnQiCMS, and how to customize the URL structure?

As an experienced CMS website operation person in the safety industry, I know that a friendly and efficient URL structure is crucial for the SEO and user experience of the website.AnQi CMS offers a wide range of options in the field of pseudo-static rules, whether it is a ready-to-use preset mode or a highly flexible custom configuration, it can meet the needs of various websites.### The AnQiCMS supported pseudo-static rules mode Pseudo-static rules can rewrite dynamic parameterized URLs into static file URLs, which makes the URLs more readable

2025-11-06

How to configure the Baidu and Bing search engine link active push in AnQiCMS?

As an experienced CMS website operator, I know the importance of search engine主动推送 for the rapid inclusion of website content and SEO optimization.AnQiCMS as a platform focusing on efficient content management, built-in convenient link push function, can help operators timely inform Baidu, Bing and other mainstream search engines of the new released or updated content, thus improving the visibility and crawling efficiency of the website.The following will elaborate on how to configure Baidu and Bing search engine link active push in AnQiCMS.

2025-11-06

How to implement document parameter filtering in AnQiCMS templates, for example, filtering by house type?

As an experienced CMS website operator for a security company, I know how important it is for users to efficiently find the content they need when visiting a website with a large amount of information.The content filtering function can not only greatly improve user experience, but also is a key factor in optimizing website structure and SEO performance.Today, I will elaborate on how to implement document parameter filtering in AnQiCMS templates, taking 'filtering by house type' as an example, to help your website better serve users.

2025-11-06

How to get all Tag lists or Tags of a specified document in AnQiCMS template?

As an experienced CMS website operations personnel in the cybersecurity field, I deeply understand the importance of content tags (Tags) in website content organization, SEO optimization, and user experience.They can not only help readers quickly find the content they are interested in, but also enhance the internal links of the website and improve the efficiency of search engine crawling.In the Anqi CMS template system, the `tagList` tag is the core tool we use to achieve this goal.This article will discuss in detail how to flexibly use the `tagList` tag in Anqi CMS template to obtain all tags on the website

2025-11-06

How to use the `system` tag to obtain website name, LOGO, filing number and other system information?

As an experienced CMS website operation personnel, I fully understand the importance of dynamically obtaining basic website information in daily template development and content presentation.To ensure the consistency, ease of maintenance, and efficient management of the website, Anqi CMS provides an extremely convenient `system` tag.This tag allows template developers to directly call various system-level data from the global settings in the background, thereby avoiding the inconvenience brought by hard coding.The website's name, logo, filing number, and other information are key elements in building a brand image and legal compliance.Pass through the `system` tag

2025-11-06

How to set the page title, keywords, description, and attach the website name using the `tdk` tag in AnQiCMS?

As a senior security CMS website operator, I am well aware of the core position of content in website construction and SEO optimization.TDK (Title, Description, Keywords) tags are an important basis for search engines to understand page content and judge the relevance of the page, as well as the information that users see first on the search results page.Efficiently setting and optimizing TDK is crucial for attracting target users and improving website rankings.Our Anqi CMS provides us with flexible and powerful TDK management functions, allowing us to finely control the metadata of each page

2025-11-06