How to filter and display a specific list of articles based on recommended properties (Flag) in AnQiCMS?

Calendar 👁️ 62

An QiCMS provides operators with a rich set of tools to organize and display website content with its flexible and efficient content management capabilities.Among them, the "recommended attribute" (Flag) is a very practical feature that allows you to easily classify and mark articles, and then implement precise content filtering and dynamic display on the website front-end.This article will introduce in detail how to use these recommended attributes in AnQiCMS to filter and display the specific article list you want.

Comprehend AnQiCMS recommendation attributes (Flag)

AnQiCMS's recommended attribute, as the name implies, is a special mark applied to articles to indicate some characteristics or importance of the article.These properties can be flexibly set when you edit the article, they are like the "tags" or "status" of the article, helping you to achieve fine-grained content presentation in the frontend template.

In the AnQiCMS backend "Add Document" interface, you will see the item "Recommended Properties". It provides a series of preset properties and their corresponding single-letter identifiers:

  • Headline [h]: Usually used for the most important and most concerned articles on the website homepage.
  • Recommend [c]: Indicates that the article is a high-quality recommended content by the editor.
  • Slide [f]: Suitable for displaying articles in slideshows or carousels.
  • Special recommendation [a]: Articles with special recommendation value.
  • Scroll [s]: Content suitable for display in scrolling news or announcement areas.
  • Bold [h]: (Note: This identifier is the same as the "Headline" attribute and may be used for visual emphasis, depending on the template implementation)
  • Image [p]: Indicates that the article has high-quality images suitable for display in the image area.
  • Jump [j]: Usually used when clicking on the article will jump to an external link.

You can select one or more recommended attributes for each article, or you can choose not to. These flexible tags are the core basis for content filtering in our front-end templates.

Apply recommended attributes to filter the article list in the template

We will mainly use recommended attributes to filter and display the article list in the AnQiCMS front-end template.archiveListThis powerful template tag.

archiveListTags providedflagandexcludeFlagTwo parameters, specifically used for handling recommendation attribute filtering requirements.

1. Filter articles with specific recommendation attributes.

If you want to display articles with a specific recommendation attribute, such as only displaying articles with the 'recommended' attribute ([c]), you can use it like thisarchiveListTags:

{% archiveList recommendedArticles with flag="c" limit="10" %}
    {% for item in recommendedArticles %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            <p>{{item.Description}}</p>
        </a>
    </li>
    {% empty %}
    <li>当前没有推荐文章。</li>
    {% endfor %}
{% endarchiveList %}

In this code block:

  • archiveList recommendedArticlesWe have defined a variablerecommendedArticlesto store the list of filtered articles.
  • flag="c"This is the key. It tells AnQiCMS to only retrieve articles marked as 'recommended'.
  • limit="10": Limit to display the latest 10 articles. You can adjust this number as needed.

It should be noted that according to the documentation of AnQiCMS,flagA parameter can only specify one recommended character at a time (such as"c"/"f"), used to selectively display articles.

2. Exclude articles with specific recommended properties

Sometimes you may want to display all articles under a certain category, but exclude those with specific recommendation attributes, such as excluding articles with the [f] attribute. At this point,excludeFlagThe parameters come into play.

{% archiveList regularArticles with categoryId="1" excludeFlag="f" limit="5" %}
    {% for item in regularArticles %}
    <li>
        <a href="{{item.Link}}">
            <h4>{{item.Title}}</h4>
        </a>
    </li>
    {% empty %}
    <li>当前没有符合条件的文章。</li>
    {% endfor %}
{% endarchiveList %}

In this example:

  • categoryId="1": Specify to filter articles only in category ID 1.
  • excludeFlag="f": Exclude all articles marked with the 'slideshow' attribute, even if they belong to the specified category.
  • withflagThe parameters are different,excludeFlagThe parameter can accept multiple recommended attribute characters, separated by commas, for exampleexcludeFlag="f,s"It indicates articles that exclude both 'slideshow' and 'scrolling' attributes.

3. Filter more accurately by combining other parameters

flagandexcludeFlagParameters can be used witharchiveListFlexibly combine other tag parameters to meet more complex filtering needs, such as:

  • Filter by model (moduleId): If you want to filter 'recommended' products in the product model, you can addmoduleId="2"(Assuming the product model ID is 2).
  • Filter by category (categoryId): As shown in the above example, you can limit attribute filtering within a specific category.
  • Sort by (order): Can be combined withorder="views desc"Display articles with specific attributes and the highest number of views.
  • Page display (type="page"): If the number of filtered articles is large, you can use the pagination feature to display them.

For example, display the latest 5 'headlines' articles in the article model (ID 1) with category ID 5:

{% archiveList headlineNews with moduleId="1" categoryId="5" flag="h" order="id desc" limit="5" %}
    {% for item in headlineNews %}
    <div class="headline-item">
        <img src="{{item.Thumb}}" alt="{{item.Title}}">
        <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
        <span>发布日期: {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
    </div>
    {% endfor %}
{% endarchiveList %}

Practical case: customize your content display

Imagine your website's homepage has a 'Featured Recommendations' section that needs to display several articles specially recommended by the editor; at the same time, in the sidebar of the article list page, you would like to display some popular articles, but you do not want the slideshow articles on the homepage to repeat.

Case One: Homepage Featured Area

`twig

Related articles

How to nested display the list of articles under the category page in AnQiCMS?

In website operation, the content classification page carries the important responsibility of organizing information and guiding users to browse.A well-designed and content-rich category page can not only improve user experience but also optimize search engine crawling efficiency.For users of AnQiCMS, nesting the list of articles under the category page is a very basic and commonly used feature.This article will introduce you in detail on how to use the powerful template tags of Anqi CMS to easily achieve this goal.Understanding the Classification Page and Content Model Before we begin

2025-11-08

How to judge and highlight the first article in the AnQiCMS article list loop?

In website content display, we often encounter the need to handle the first element of the article list specially.In order to achieve visual prominence, to implement unique layout design, or to give the first article more attention, AnQiCMS provides flexible and powerful template tags to help us easily achieve this goal.AnQiCMS uses a syntax similar to the Django template engine, where the `for` loop tag plays a core role in processing content lists.When we use `archiveList`

2025-11-08

How to display the reading views of articles on the AnQiCMS article list or detail page?

In website content operation, the number of article views is an important indicator, which helps us understand the popularity of the content and the user's interests.AnQiCMS provides a convenient way for you to visually display this data on the article list page or detail page. ### Understanding AnQiCMS's Page View Mechanism AnQiCMS is a comprehensive content management system that comes with a built-in mechanism for automatically recording article page views.

2025-11-08

How to format the display of the publication and update time of articles in the AnQiCMS template?

In Anqi CMS website templates, displaying the publication and update time of articles is a key factor in improving user experience and content management efficiency.Clearly present this time information, which not only helps visitors quickly understand the timeliness of the content, but also assists search engines in better crawling and indexing.AnQiCMS provides a powerful and flexible template tag that allows you to format timestamps into various easily readable date and time formats as needed.### Core Mechanism: `stampToDate` tag The template system of Anqi CMS is built-in with a named

2025-11-08

How does AnQiCMS display the list of all top-level categories?

In website construction and content operation, clear classification navigation is the foundation of user experience, as well as the core of content organization.For users using AnQiCMS, how to efficiently display the list of all top-level categories of the website is the first step in building the website structure.AnQiCMS with its flexible template engine and rich built-in tags makes this task exceptionally simple and intuitive.

2025-11-08

How to display the subcategory list under the AnQiCMS category page?

In AnQiCMS, you can easily display the subcategory list under the category page with flexible template tags.This is crucial for building a clear website structure, improving user navigation experience, and optimizing search engine crawling efficiency.AnQiCMS powerful template system and its Django-style tag syntax make the display of such dynamic content intuitive and efficient.To implement displaying the subcategory list under the category page, the following steps are mainly involved:

2025-11-08

How to implement nested display of multi-level categories in AnQiCMS navigation menu?

In website construction, a clear and easy-to-use navigation menu is crucial for improving user experience and the overall structure of the website.AnQiCMS provides flexible settings for managing the navigation menu, allowing users to easily implement nested hierarchical classification display, thereby better organizing website content and guiding visitors to explore.To implement multi-level nested navigation, we mainly complete it through the "Navigation Settings" function in the AnQi CMS backend.This feature is located in the "Background Settings" area, it can not only manage the top navigation of the website, but also create various custom navigations as needed

2025-11-08

How to obtain and display the detailed description information of AnQiCMS categories?

In website operation, clear and detailed classification descriptions are crucial for user experience and search engine optimization.AnQiCMS as a powerful content management system provides a flexible way to manage and display these category information.This article will delve into how to retrieve and effectively display detailed category descriptions on the frontend page in AnQiCMS.

2025-11-08