How to filter and display a list of articles based on their recommended attributes (such as “Top Article”, “Recommended”)?

Calendar 👁️ 66

In Anqi CMS, efficient content management is one of the key factors for website success.Article recommendation attribute, as an important part of content refined operation, it can help us display website content more flexibly, guide users to focus on key information, thereby improving the activity and conversion rate of the website.This article will delve into how to filter and display an article list based on the recommended attributes of the article (such as "Headline

Understanding the article recommendation attributes of Anqi CMS

AnQi CMS provides rich recommendation attribute settings for each published article.These properties are like the 'tags' of an article, used to mark the importance, type, or display requirements at a specific location.By reasonably setting these properties, we can easily control the display of articles in different areas of the website.

The system built-in multiple recommended properties, each property corresponds to a specific letter identifier, convenient for calling in the template:

  • Headline[h]: Often used for the most prominent news or announcements on the homepage of a website.
  • Recommended[c]: Indicates high content quality and is worth recommending to users.
  • Slide[f]: Often used for articles in the carousel or focus image area.
  • Special recommendation[a]: Articles with more specificity or exclusivity than 'Recommended.'
  • Scroll[s]: Suitable for news flashes, bulletin boards, and other short messages that need to be scrolled.
  • Bold[h]: May share the identifier with the 'Top News' attribute, usually used to highlight article titles in lists.
  • Image[p]This indicates that the article content contains important images or elements that need to be highlighted during display.
  • Jump [j]This is used to mark the article link as an external link, which will jump directly to another page when clicked.

When editing articles in the background, you can select one or more properties in the "Recommended Properties" option according to the actual situation of the article.These operations are very intuitive, just find the corresponding options on the article editing page to select them.

Filter and display the article list in the front-end template

Apply these recommended properties to the front-end display of the website, which is the core of enhancing content operation effects. Anqi CMS provides powerful template tag functions, among whicharchiveListTags are the key to achieving this goal.

1. UseflagParameters for precise filtering.

archiveListlabel'sflagThe parameter allows you to filter the list of articles to be displayed based on the recommended attributes of the articles. For example, if you want to display all articles marked as "top news" in a certain area on the homepage, you can useflag="h":

{% archiveList archives with type="list" flag="h" limit="5" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            <p>{{item.Description}}</p>
        </a>
    </li>
    {% empty %}
    <li>暂无头条文章。</li>
    {% endfor %}
{% endarchiveList %}

Please note: Being calledarchiveListWhen labeling, each list can only specify one recommended attribute for filtering.If you need to meet multiple attributes of an article, you may need to adjust the content release strategy or call and merge the display in multiple times.

2. UseexcludeFlagExclude articles with specific attributes

In addition to filtering articles with specific attributes, you can also useexcludeFlagParameters to exclude certain attributes of the article.This is very useful when it is necessary to avoid content repetition.

{% archiveList archives with type="list" flag="c" excludeFlag="h" limit="10" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h4>{{item.Title}}</h4>
            <p>{{item.Description}}</p>
        </a>
    </li>
    {% empty %}
    <li>暂无其他推荐文章。</li>
    {% endfor %}
{% endarchiveList %}

This code filters out all articles marked as "recommended", while excluding those also marked as "headlines", ensuring differentiated content display.

3. Enhance filtering accuracy by combining other parameters

archiveListLabels also support other parameters, such ascategoryId(Category ID),moduleId(Model ID),limit(Number of items displayed) andorder(Sorting method), you can combine them withflagorexcludeFlagCombine use to achieve more accurate article list display. For example, display the latest 5 recommended articles under a specific category:

{% archiveList archives with type="list" categoryId="10" flag="c" order="id desc" limit="5" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <img src="{{item.Thumb}}" alt="{{item.Title}}">
            <h3>{{item.Title}}</h3>
        </a>
    </li>
    {% endfor %}
{% endarchiveList %}

4. Show article recommendation attribute identification

If you want to display the recommended attributes of each article in the article list directly, you can useshowFlag=truethe parameter. After setting it, you can go throughitem.FlagTo obtain the recommended attribute letters of the article and combine it with CSS for style rendering, for example, add a red corner mark to the "top news" article.

{% archiveList archives with type="list" showFlag=true limit="10" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}
                {% if item.Flag contains "h" %}<span>[头条]</span>{% endif %}
                {% if item.Flag contains "c" %}<span>[推荐]</span>{% endif %}
            </h5>
            <p>{{item.Description}}</p>
        </a>
    </li>
    {% endfor %}
{% endarchiveList %}

This has been usedcontainsTo judgeitem.FlagDoes the string contain a letter of a certain attribute, because an article may have set multiple recommended attributes.

Summary

The Anqi CMS article recommendation feature provides great flexibility for website content operation. By proficiently usingarchiveListlabel'sflag/excludeFlagParameters such as these, you can accurately filter and display article lists according to different operational strategies and page requirements, thereby optimizing the user's browsing experience and enhancing the exposure and attractiveness of the website's content.Flexibly combine these features to help you better manage and present the valuable content of the website.

Frequently Asked Questions (FAQ)

  1. Question: Can I use the samearchiveListIn the tag, filter multiple recommended attributes at the same time, for example, articles that are both 'headline' and 'recommended'?Answer: Anqi CMS'archiveListTags are filtered in the selection,flagThe parameter can only specify one recommended attribute at a time. This means you cannot directly go throughflag="hc"This way to filter articles that have both the 'Headline' and 'Recommendation' attributes. If you need to achieve a similar effect, you may need to set a separate recommendation attribute for articles that have both of these features when the articles are published, or by using two differentarchiveListCall and combine front-end logic to handle.

  2. Question: If an article has set multiple recommendation attributes (such as "Top[h]" and "Slide[f]"), when I call in the front-endarchiveListUseflag="h"Will this article containing multiple properties be displayed?Answer: Yes. When you callflag="h"When, all articles that contain the recommendation attribute "h" at least will be filtered out, regardless of whether they also have other recommendation attributes.flagThe parameter is for matching whether the article "includes

  3. Ask: I have set the recommendation attribute for the article in the background, but the front-end page does not display as expected. What could be the reason?Answer: This usually has several common reasons. First, please check the template code in yourarchiveListlabel'sflagThe parameters are filled in correctly and consistent with the recommended attribute letter identifier set in your background (case-sensitive). Secondly, confirmarchiveListOther parameters of the tag, such ascategoryId/moduleIdorlimitWhether it unintentionally restricted the display of the article.After making changes to the content in the Anqicms background, sometimes you need to clear the system cache to see the latest effects on the front page. You can try to perform operations in the 'Update Cache' feature of the background management interface.

Related articles

How to display articles under a specific category without including its subcategories?

In website content management, we often encounter such needs: we want to display articles under a specific category on a page, but we don't want to include the sub-category articles under that category to maintain the purity and focus of the content.For example, you may have a "Company News" category that includes subcategories such as "Enterprise Dynamics" and "Industry Information", but on the homepage, you only want to display the pure "Company News" without mixing in the content of all subcategories.

2025-11-08

How to exclude specific categories or multiple categories of articles from the document list?

When managing website content in Anqi CMS, we often need to precisely control the display of articles.Sometimes, we may want certain category articles not to appear in the regular article list, such as for internal notifications, test content, or some promotional information that is only displayed on specific pages.AnQi CMS provides a simple and efficient method to meet this kind of need, allowing you to flexibly exclude articles of specific categories or multiple categories, thereby achieving more accurate content presentation.

2025-11-08

How to filter and loop through the document list under a specific category based on the category ID?

It is crucial to organize and present content when building and operating a website.Especially when the content of a website becomes increasingly rich, how to enable visitors to quickly find the information they are interested in and clearly browse all articles under a specific theme has become a carefully designed problem.AnQiCMS (AnQiCMS) provides powerful and flexible content management capabilities, allowing us to easily achieve precise control and display of document lists.

2025-11-08

How to display the latest N articles or products on the homepage and implement pagination control?

## Asecurity CMS: The Practice of Efficiently Displaying the Latest Content on the Homepage and Implementing Pagination The homepage is an important entry point for visitors to understand the site content and obtain the latest information, it is crucial to clearly and effectively display the latest published articles or products.The AnQi CMS provides powerful and flexible template tags, which help us easily achieve this goal, and can also fine-tune content pagination to ensure a smooth user experience.

2025-11-08

How to display the article list according to the article views, publish time, or backend custom sorting?

In website operation, the way articles are displayed directly affects user experience and content access efficiency.A well-organized list of articles that can highlight key points, significantly improving user retention and information acquisition efficiency.AnQiCMS as a flexible content management system provides powerful article list display functions, not only can it flexibly filter content, but also can freely adjust the sorting method of articles according to your content strategy, making your website content more attractive.

2025-11-08

How to obtain and display the title, content, thumbnail, and other core information of an article on the article detail page?

When operating a website, the article detail page is the key entry point for users to understand the core value of the content.A well-designed, comprehensive article detail page that not only improves user experience but also effectively helps search engines understand the content of the page, thus optimizing the website's SEO performance.AnQiCMS (AnQiCMS) provides a powerful and flexible template tag system that allows you to easily obtain and present all the core information of the article.

2025-11-08

How to retrieve the custom fields (such as author, source, additional parameters) of the current article and display them?

In Anqi CMS, managing and displaying custom fields for articles such as authors, sources, or additional parameters is a common and practical need in content operation.The Anqi CMS, with its flexible content model design, provides multiple ways to achieve this goal, helping you easily enrich article information and present it to readers in a personalized manner. ### Understanding AnQi CMS Custom Fields Firstly, we need to understand how article custom fields work in AnQi CMS.

2025-11-08

How to dynamically fetch and display the previous and next articles of the current article on the article detail page?

In website operation, how to allow users to smoothly jump to related or the next article after reading an article is the key to improving user experience and website stickiness.Especially for sites with a large amount of content, such as blogs, information stations, or product display websites, a intuitive 'Previous/Next' navigation function is particularly important.It can not only guide users to deeply browse and reduce the bounce rate, but also provide more internal links for search engines to optimize the SEO performance of the website.AnQiCMS (AnQiCMS) is a powerful content management system that fully considers this need

2025-11-08