How to filter document lists in AnQi CMS based on recommended attributes (such as headlines, recommendations)?

Calendar 👁️ 77

AnQi CMS is an efficient content management system that provides a variety of features to help operators manage and display website content.Among the "Recommended Properties" feature, it is a very practical tool that allows us to mark documents flexibly, thus enabling dynamic filtering and displaying specific content in different areas of the website.This article will discuss in detail how to use recommendation attributes in Anqi CMS to filter document lists, making the website content more vibrant and attractive.

Part 1: Understanding the recommended attributes of AnQi CMS

In the AnQi CMS backend, when we publish or edit a document, we will see a setting item named "Recommendation Properties".These properties are like different tags attached to an article to indicate its importance, eligibility for display at specific locations, or special display effects.The system is built-in with a variety of recommended attributes, each attribute corresponds to a short letter identifier, convenient for calling in templates:

  • Headline [h]: Typically used in the most prominent position on the website homepage, displaying the most important and most concerned content.
  • Recommend [c]: Refers to high-quality content recommended by editors, which can appear in multiple recommended positions.
  • Slide [f]: Often used in carousel or large focus image areas, attracting the attention of users.
  • Special recommendation [a]: Especially recommended content, which may have higher weight or an independent display area.
  • Scroll [s]: Suitable for continuous display in news scrolls, bulletin boards, and other scenarios that require continuous display.
  • Image [p]: Indicates that the content is suitable for display mainly in the form of images, such as image news or albums.
  • Jump [j]This indicates that the document is an external link or an in-site jump, clicking on it will directly jump to the specified URL.

When editing documents in the background, we can select one or more recommended properties based on the importance of the content or the expected display effect.For example, a recent important news can be set as both 'headline' and 'recommendation', while a beautifully crafted product album can be set as 'slideshow' and 'image'.This flexible marking method lays a foundation for the dynamic display of front-end content.

Part two: How to use recommended attributes to filter document lists in the template.

We need to use the powerful Anqicms template to filter and display the document list according to these recommended properties on the front end of the websitearchiveList.archiveListTags allow us to specifyflagParameters to filter documents with specific recommendation properties.

flagThe parameter accepts a single recommended attribute letter identifier. Although multiple recommended attributes can be selected for a document in the background editing of the document, in the front-end template, eacharchiveListcall,flagParameters usually correspond to a recommended attribute for filtering.

Here is a basicarchiveListexample of tag usage, used to filter out articles set to the "headline" attribute:

{# 筛选出最新5篇设置为“头条”属性的文章 #}
<div class="headlines-section">
    <h2>最新头条新闻</h2>
    <ul>
        {% archiveList topNews with moduleId="1" flag="h" limit="5" order="id desc" %}
            {% for item in topNews %}
                <li class="news-item">
                    <a href="{{ item.Link }}" title="{{ item.Title }}">{{ item.Title }}</a>
                    <span class="publish-date">发布日期: {{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                </li>
            {% else %}
                <p>当前暂无头条新闻。</p>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Code analysis:

  • {% archiveList topNews with ... %}This is the core tag for calling the document list.topNewsThis is the variable name defined for this query result, which you can use in the loop.
  • moduleId="1": Specify the content model ID to be queried. AnQi CMS defaults to article model ID 1, product model ID 2. Fill in according to actual needs.
  • flag="h": This is the key parameter of this topic, it tells the system to only filter out documents marked as 'Top News' attribute (h) of the document.
  • limit="5": Limit the number of displayed documents to 5.
  • order="id desc": Sort by document ID in descending order, which usually means the latest released documents are at the top. You can also adjust according toviews desc(view count in descending order) orsort desc(custom sorting on the backend) and so on.
  • {% for item in topNews %} ... {% endfor %}: TraversetopNewsThe document list obtained in the variable.
  • item.Linkanditem.Title: Retrieve the link and title of the document separately.
  • item.CreatedTimeandstampToDate(...):item.CreatedTimeGet the creation timestamp of the document,stampToDateThe filter formats it into a readable date format of 'Year-Month-Day'.
  • {% else %} ... {% endfor %}If no documents matching the criteria are found, the alternative content here will be displayed.

By flexible adjustmentflagThe value of the parameter, combined with other filtering conditions, allows you to build various dynamic and accurate document lists.

Part three: practical examples and code analysis

Below are several practical examples that further demonstrate how to filter document lists based on recommended attributes to meet the different content display needs of various websites.

Example one: Display area of the homepage slider

Assuming your website homepage has a carousel

Related articles

How to sort the document list of Anqi CMS by views or publish time?

How to effectively organize and present content in website construction and operation is the key to improving user experience and content discovery efficiency.For friends using AnQiCMS, it is very practical to flexibly sort the document list.Whether it is to make visitors see the most popular articles first or the latest updates, AnQiCMS provides a simple and powerful way to achieve this.

2025-11-08

How can AnQi CMS display a list of documents under a specified category and perform pagination?

AnQiCMS (AnQiCMS) with its flexible template mechanism and powerful content management features makes the display of website content very simple and efficient.For many websites, clearly displaying content by category and providing convenient pagination navigation is the key to improving user experience and optimizing search engine rankings.Let's learn together how to easily implement document list display and pagination functions under specified categories in Anqi CMS.### Flexible configuration, control content display Anqi CMS template system uses syntax similar to Django template engine

2025-11-08

How to display content from a specific site by using label parameters in a multi-site environment?

When using AnQiCMS for website management, the multi-site feature undoubtedly brings great convenience to users with multiple brands, sub-sites, or content branches.It allows us to efficiently manage multiple independent websites on a unified backend.However, in actual operation, we sometimes encounter a specific requirement: to display the content of another specific site on a site.For example, the main site wants to reference some of the latest articles from the child site, or a specific thematic site wants to display product information from another cooperative site.At this moment, 'How to set up an environment across multiple sites'

2025-11-08

How to troubleshoot when the AnQiCMS program is upgraded and the front-end page does not update?

How to troubleshoot when the front page does not update after the AnQiCMS program upgrade? When you eagerly upgraded the AnQiCMS program, expecting new features and optimizations to immediately appear on your website, only to find that the front page remained unchanged and stuck in the old version, that feeling is indeed quite crazy.Don't worry, this is usually not a big problem, mostly due to caching or program loading mechanisms.Today we will work together to investigate in detail and see how to make your website's front-end look brand new.

2025-11-08

How to exclude specific category content from the document list?

In website operation, we often need to flexibly control the display of content.For example, you may want to display the latest articles on the homepage, but not include a specific category such as "internal notices" or "archived content";Or in a product list, you want to exclude those categories that are "discontinued" or "internal testing", to keep the user interface simple and clear. A security CMS provides very convenient and powerful functions to meet such needs.By cleverly using the template tag `archiveList`

2025-11-08

How to achieve accurate display of in-site search results in Aiqi CMS?

The importance of on-site search functionality in daily website operation is self-evident.It is not only a bridge for users to quickly find the information they need, but also a key link to improve user experience, extend visit duration, and even promote conversion.If a user enters a keyword and gets a bunch of irrelevant results, they are likely to leave quickly.Therefore, how to achieve accurate display of in-site search results in AnQiCMS is a topic that every content operator should delve into.AnQiCMS is a system specially designed for content management, with a powerful and flexible search mechanism and content organization capabilities

2025-11-08

How to retrieve and display the complete content and all fields of a single document?

One of the core values of a content management system is the ability to flexibly define and present various types of content.For users of AnQiCMS, whether it is to display a detailed article, a product page, or a custom data entry, how to efficiently obtain its complete content and all associated fields is the key to front-end template development and content presentation.Today, let's delve into how to easily control the acquisition and display of individual document content in AnQiCMS using this '万能钥匙' template tag.

2025-11-08

How can AnQi CMS enable lazy loading display for images in document content?

In today's online environment, the loading speed of a website is one of the key factors in user experience and search engine ranking.When web page content includes a large number of images, these images often become the 'culprits' that slow down loading speed.Imagine a user opening a page, even if they haven't scrolled to the bottom of the page, the browser has already started downloading all the images, which undoubtedly consumes valuable bandwidth and processing resources, resulting in slow page response.In order to solve this pain point, the Lazy Loading technology for images was born.

2025-11-08