How to filter and display the document list based on recommended properties (Flag)?

Calendar 👁️ 74

As an experienced website operations expert, I know that the powerful function of the Content Management System (CMS) lies in its flexibility and ease of use.In AnQiCMS (AnQiCMS), the 'Recommended Attribute' (Flag) of the document is such a seemingly simple feature, but it can greatly improve the efficiency of content operation and the diversity of website display.Today, let's delve into how to skillfully use recommendation attributes to achieve precise filtering and display of document lists.

Understanding the 'recommended attributes' (Flag) of Anqi CMS

In Anqi CMS, when we publish or edit a document, in addition to the basic information such as title, content, and category, we will also see a very practical option called 'Recommended Properties'.These properties are like special tags applied to documents, which do not affect the document's classification, but are used to mark the characteristics or importance of the document so that it can be displayed or filtered specially on the website front-end.

AnQi CMS provides eight preset recommended attributes, you can select one, multiple, or even none for documents according to actual operational needs. These attributes correspond to simple letter identifiers, they are:

  • Headline [h]: It is usually used to mark the most important articles that need to be highlighted.
  • Recommend [c]: Indicates that the content quality is high and worth recommending to users.
  • Slide [f]:Used for documents displayed in slideshows or carousels, images are usually the focus.
  • Special recommendation [a]:Documents with special significance or those that need to be particularly recommended.
  • Scroll [s]: Suitable for displaying brief information on bulletin boards or scrolling news.
  • Bold [h]: Hint to the front-end to bold the title or other text to emphasize when displayed.
  • Image [p]Indicates that the document primarily contains images or emphasizes the display of images.
  • Jump [j]Used to mark special documents that will jump to external links instead of the document details page when clicked.

These settings are very intuitive, located in the "Content Management" module on the back end. When you add or edit documents, you can find the "Recommended Properties" option to check on the interface.

Core Tool:archiveListThe clever use of tags

In AnQi CMS template design, we mainly usearchiveListTag to retrieve and display a list of documents. This tag is powerful, supporting various parameters to control the source, sorting, and display method of the list. To filter documents based on recommended properties,flagandexcludeFlagThese two parameters are the core of our matter.

archiveListThe basic usage of the tag is like this:

{% archiveList 变量名称 with 参数1="值1" 参数2="值2" %}
    {% for item in 变量名称 %}
        {# 在这里循环显示文档内容 #}
    {% endfor %}
{% endarchiveList %}

Among them,变量名称It is a name you customize for the document list you obtain, for examplearchives/latestNewsetc.

Guide to practical application: Filtering documents based on recommended attributes

Now, let's see how to actually apply these recommended attributes to filter and display documents in a template.

1. Filter documents showing specific recommended properties

Assuming you want to display only those documents marked as 'Top News' in a specific area of the homepage. You can useflagParameters, and pass the corresponding letter identifier.

{# 示例:在首页显示5篇“头条”文档 #}
<div class="headline-articles">
    <h2>今日头条</h2>
    <ul>
        {% archiveList headlines with flag="h" limit="5" %}
            {% for item in headlines %}
                <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
            {% empty %}
                <li>暂无头条文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In this example,flag="h"TellarchiveListThe tag only retrieves documents with the 'Top News' attribute.limit="5"This limits the number of displayed items to 5.{% empty %}A block is a very friendly design, when there are no documents that meet the conditions, it will display 'No headline articles available', to avoid the page from being blank.

2. Exclude documents with specific recommendation attributes.

Sometimes, you might want to display the vast majority of documents but exclude certain specific attributes.For example, you have a regular list of articles, but you don't want documents marked as "slide" to appear here because they have already been displayed in the carousel area.excludeFlagThe parameters come into play.

{# 示例:显示最新文章,但排除掉“幻灯”文档 #}
<div class="latest-articles">
    <h2>最新动态</h2>
    <ul>
        {% archiveList regularContent with excludeFlag="f" order="id desc" limit="10" %}
            {% for item in regularContent %}
                <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
            {% empty %}
                <li>暂无最新动态。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

here,excludeFlag="f"Documents with the 'slide' attribute were ensured not to appearregularContentin the list.order="id desc"Then, documents are displayed in reverse chronological order, showing the most recent ones.

3. Display recommended property indicator in document list

If you want users to see at a glance that a document has special recommended attributes, you can display a mark next to the document title.archiveListTags providedshowFlag=trueA parameter that includes all recommended attribute letter strings (such as "hc") in the documentitem.Flagin the field.

”`twig {# Example: Display recommended documents and note properties next to the title #}

Related articles

How to implement pagination and page number display for article lists in AnQi CMS?

As an experienced website operations expert, I am well aware of the crucial role of a powerful and easy-to-use content management system for the success of a website.AnQiCMS (AnQiCMS) boasts a high-performance architecture based on the Go language and flexible template mechanism, providing an excellent experience in content publishing and management.Among them, efficiently displaying a large amount of content, especially implementing the pagination function of the article list, is an indispensable factor in improving user experience and website SEO performance.Today, let's delve deeply into how AnQi CMS cleverly implements this feature and demonstrates friendly page navigation.--- ##

2025-11-06

How to get the list of articles under a specified category in AnQiCMS?

## Easily retrieve the list of articles under a specified category in AnQiCMS As an experienced website operations expert, I fully understand the core value of a content management system (CMS) lies in its ability to organize and present content.Among many features, how to efficiently extract and display articles from a specific category is an indispensable part of the daily work of website operators.Today, let's delve deep into how AnQiCMS can help you achieve this goal, making technical details intuitive and easy to understand.

2025-11-06

Unveiling AnQi CMS: How Markdown content is beautifully presented on your website?

AnQi CMS is an efficient content management system that knows well the pursuit of convenience by content creators.Markdown is a lightweight markup language that is favored by content editors for its concise, easy-to-learn, and clear formatting features.How can we ensure that the wonderful content you write in Markdown in Anqi CMS can be perfectly converted into browser-readable HTML and displayed on the front-end page without any loss?

2025-11-06

How to call custom document fields (such as author, price) and display them in AnQi CMS?

AnQi CMS offers powerful content management capabilities with its excellent flexibility and customizability to website operators.In the daily operation of websites, we often encounter situations where standard fields (such as titles, content, and publication time) cannot fully meet the needs of specific content display.At this moment, custom document fields have become our powerful assistants, for example, adding "author" information to an article, or supplementing "price" attributes to a product, and so on.How can we flexibly call these custom fields and display them on the website page in Anqi CMS today?

2025-11-06

How to sort the document list by publication time or views?

In the world of website operation, the organization and presentation of content directly affects the user experience and the efficiency of information transmission.AnQiCMS (AnQiCMS) as an efficient content management system, fully understands the importance of this requirement, and therefore provides powerful and flexible options for sorting document lists, allowing you to easily control the display priority of content according to different operation goals.Today, let's delve into how to sort document lists in Anqi CMS using publication time or views.

2025-11-06

How to exclude certain specific categories of articles from the AnQiCMS document list?

During the operation of the website, we often need to manage and display content in a fine-grained manner.For example, we may wish to hide certain internal announcements, specific promotional content, or some draft category articles that are not suitable for external display when recommending articles on the homepage.AnQiCMS (AnQiCMS) is a powerful content management system that fully considers such needs and provides a simple and flexible way to achieve this - by specifying exclusion parameters in the document list tag.This article will delve into how to exclude certain categories of articles from the document list in AnQiCMS

2025-11-06

How to implement the 'related articles' recommendation feature in AnQiCMS?

As an experienced website operations expert, I am well aware of the importance of the 'related articles' recommendation feature for improving user experience, extending user stay time, reducing bounce rate, and optimizing the internal link structure of the website (SEO).AnQiCMS (AnQiCMS) provides a flexible and efficient solution in this regard, allowing website operators to easily implement intelligent content recommendations.

2025-11-06

How to perform keyword search on the AnQiCMS document list page?

Good, as an experienced website operations expert, I am happy to write a practical guide for you on how to perform keyword search in the AnQiCMS document list page. --- ## Efficient Keyword Search on AnQiCMS Document List Page: A Practical Guide Quickly locating and managing a large number of documents is crucial for improving efficiency in daily content operations.With the continuous enrichment of website content, we often need to accurately retrieve specific articles or products from the vast sea of information.

2025-11-06