How to use the AnQiCMS recommendation attribute (flag) to filter and display specific content, such as "headline" or "slideshow"?

Calendar 👁️ 79

AnQiCMS provides a flexible recommendation attribute (flag) mechanism that allows website operators to easily filter and highlight specific content, whether it's the 'Top News' on the website homepage, the 'Slideshow' in the carousel, or other 'Recommended' content that needs special attention.This feature greatly enhances the efficiency of content operation and the richness of website content.

Understand recommendation attributes: Apply "exclusive tags" to content

Imagine that you have published many excellent articles and product information, but there are always some that are the most important, most popular, or need to be displayed in specific locations.The recommended attribute of Anqi CMS is a set of 'tags' system created for this purpose.It allows you to add one or more special tags to the content outside of the usual categories and labels.

These recommended properties are called "flag" in the background, and they are represented by a simple letter to indicate different types of recommendations. Currently, AnQi CMS supports the following commonly used recommendation properties:

  • Headline[h]: Usually used to display the most important and eye-catching news or articles.
  • Recommended[c]: Indicates that the content is recommended high-quality content by the editor.
  • Slide[f]: Designed specifically for the homepage or specific area carousel (slideshow).
  • Featured[a]: Different from ordinary recommendations, used for special recommended content.
  • Scrolling[s]: Suitable for news scrollbars, marquee displays, and other content that needs to be scrolled.
  • Bold[h]: This is a repeated marker that may emphasize the visual importance of the content title semantically.
  • Image[p]: Emphasize that the content contains high-quality images, which may be used in photo specials or albums.
  • Jump[j]: Identifies the content that will jump to an external link or specified page when clicked.

By these properties, we can finely control the display form and priority of content on the front-end page.

Set recommended properties for content in the background.

It is very intuitive to set recommendation attributes for content. When you edit or publish a document in the Anq CMS backend, on the "Add Document" or "Edit Document" page, you will see an option called "Recommendation Attributes".

Here, you can select one or more recommended attributes based on the characteristics of the content and your operational needs. For example, if you want to display a newly released product information on the home page slider area and also mark it as editor 'recommended', you can check them at the same time.幻灯 [f]and推荐 [c].

The flexibility of Anqi CMS is reflected in the fact that you can set multiple recommended attributes for the same piece of content, which means that a piece of content can be both a "headline" and a "slider", displayed in different front-end areas.

Filter and display specific content in the front-end template

After setting up the recommended properties, the next step is to filter and display content in the front-end template of the website based on these properties. This is mainly achieved byarchiveListTemplate tags can be used to achieve this.

archiveListTags are the core tools in AnQi CMS used to obtain document lists, providing rich parameters to help us precisely control the acquisition of content. Among them,flagThe parameter is used to specify the recommended attributes we want to filter.

It should be noted that in a singlearchiveListTag call in progress,flagA parameter can only specify one property letter. This means that if you want to display the content of both "Headline" and "Slide" at the same time, you need to use two separatearchiveList.

Below, let's look at how to operate with some examples:

Example one: Display 'Top News' on the homepage

Assume you want to display 5 of the latest "headlines" prominently on the home page of the website.

<div class="headline-news">
    <h2>头条新闻</h2>
    <ul>
        {% archiveList headlines with flag="h" limit="5" order="id desc" %}
            {% for item in headlines %}
                <li>
                    <a href="{{ item.Link }}">
                        <h3>{{ item.Title }}</h3>
                        <p>{{ item.Description | truncatechars:80 }}</p> {# 截取前80个字符作为简介 #}
                    </a>
                </li>
            {% empty %}
                <li>暂无头条新闻。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In this example:

  • flag="h"Tell the system to only retrieve content marked as "headline".
  • limit="5"Limit to displaying only the latest 5 articles.
  • order="id desc"Make sure to get the latest released (ID in descending order).
  • item.Linkanditem.TitleUsed to display the link and title of the article.
  • item.Description | truncatechars:80It will display the article summary and truncate it to 80 characters.
  • {% empty %}It is a very practical grammar, when the front end does not match the content, it will display “No headline news.”.

Example two: Create the “slideshow” carousel on the homepage.

If we need to display 3 slides at the top of the homepage, these slides usually contain images and links.

<div class="main-slider">
    <div class="swiper-wrapper">
        {% archiveList slides with flag="f" limit="3" order="id desc" %}
            {% for item in slides %}
                <div class="swiper-slide">
                    <a href="{{ item.Link }}">
                        {% if item.Thumb %}
                            <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                        {% else %}
                            <img src="/public/static/images/default-slide.jpg" alt="默认幻灯片"> {# 假设有个默认图 #}
                        {% endif %}
                        <div class="slide-caption">{{ item.Title }}</div>
                    </a>
                </div>
            {% empty %}
                <div class="swiper-slide">暂无幻灯片内容。</div>
            {% endfor %}
        {% endarchiveList %}
    </div>
    <!-- Add Pagination, if required -->
    <div class="swiper-pagination"></div>
</div>

Here:

  • flag="f"Explicitly indicates that we only get content marked as 'slides'.
  • item.ThumbUsed to display the thumbnail for content settings, which is usually the main image for slides.item.LogoIt can also be used in some cases.
  • We also added a judgment, ifitem.ThumbIf not found, display a default image to ensure the page is aesthetically pleasing.
  • The specific slide carousel effect usually requires coordination with a front-end JavaScript library (such as Swiper.js) to implement, and here only the content acquisition method is displayed.

Example three: Display recommended products under a specific category

In addition to the homepage, we can also display products marked as 'recommended' under a specific category page.

{% categoryDetail currentCategory with name="Id" %} {# 获取当前分类ID #}
<div class="recommended-products">
    <h3>本分类推荐产品</h3>
    <div class="product-grid">
        {% archiveList recommendedProducts with moduleId="2" categoryId=currentCategory flag="c" limit="4" order="sort desc" %}
            {% for item in recommendedProducts %}
                <div class="product-item">
                    <a href="{{ item.Link }}">
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                        <h4>{{ item.Title }}</h4>
                        <p class="price">¥ {{ item.Price }}</p> {# 假设产品模型有Price字段 #}
                    </a>
                </div>
            {% empty %}
                <p>当前分类暂无推荐产品。</p>
            {% endfor %}
        {% endarchiveList %}
    </div>
</div>

In this scenario:

  • We first pass through{% categoryDetail currentCategory with name="Id" %}Got the ID of the current category.
  • moduleId="2"Ensure that we only get the content under the 'Product Model' (assuming the Product Model ID is 2).
  • categoryId=currentCategoryLimit the content to the current category.
  • flag="c"Filter products marked as "Recommended".
  • item.PriceDisplays the price in the product custom fields, enriching the product information.

Through these flexible combinations, AnQi CMS's recommended attribute feature makes content presentation more intelligent and personalized.It not only improved the content exposure, but also provided users with more accurate and valuable information.

Frequently Asked Questions (FAQ)

Can I set multiple recommendation attributes for a content at the same time?Yes, Anqi CMS allows you to select multiple recommended attributes for the same document. For example, you can make an important article have both "top"[h]"and "slide"[f]"Property, so that it can be displayed in different forms in different areas of the website."

2. Can I filter multiple recommended properties in onearchiveListtag at the same time?No.archiveListlabel'sflagThe parameter is designed to accept only one recommended attribute letter at a time. If you need to display different recommended attribute content on a page (for example, one area displaying "Top News", another area displaying "Recommendation"), you need to use multiplearchiveListTags, each tag is set differentlyflagValue.

3. If I have set the recommended attribute but the content is not displayed on the front-end page, what could be the reason?There could be several reasons:

  • The content has not been published or has expired:Make sure the recommended attribute content you have set has been published, and the publish time is within the valid period (if no scheduled publication has been set).
  • Template code error:Check your template code to ensurearchiveListin the labelflagThe parameter letters match the letters of the properties set in your background and there are no other spelling errors.
  • No matching content:Make sure the content is indeed set with the corresponding recommendation attribute. Try in the background

Related articles

Does AnQiCMS support setting custom templates for pages of different categories to achieve differentiated display?

In website operation, we often encounter such needs: different types of content or pages with different themes need to be presented in a unique way to better attract visitors, convey information, and even enhance the brand image.This involves the customization ability of the template.AnQiCMS (AnQiCMS) indeed provides strong and flexible support in this aspect, allowing users to set custom templates for pages of different categories to achieve differentiated content display.

2025-11-09

How to configure the pagination display style of the content list in AnQiCMS to improve user experience?

In AnQiCMS, optimizing the pagination display of the content list is crucial for improving the user browsing experience.A well-designed, easy-to-use pagination system not only helps visitors efficiently find information but also improves the website's SEO performance.AnQiCMS provides intuitive and powerful template tags, allowing us to easily achieve these goals.

2025-11-09

How to call and display the thumbnail or cover image of AnQiCMS template, what processing methods are supported?

In website content operation, images play a vital role. They can attract users' attention, enhance the beauty of the page, and are an indispensable part of search engine optimization (SEO).AnQiCMS provides flexible and diverse mechanisms to handle and display thumbnails or cover images for articles, categories, single pages, etc. Whether it is automated processing in the background or fine control at the template level, it can meet all kinds of content operation needs.

2025-11-09

How to use the pseudo-static feature of AnQiCMS to optimize the URL structure to improve the crawling and display effect of search engines?

## Utilizing AnQiCMS's SEO-friendly URL structure: A practical guide to improving search engine crawling and display effectiveness in the digital marketing wave In today's digital marketing wave, Search Engine Optimization (SEO) has become one of the key factors for website success.A clear, friendly, and semantically rich URL structure is undoubtedly the cornerstone of improving a website's SEO performance.It not only helps search engines crawl and understand your content more efficiently, but also significantly improves the reading experience and memorability of users.

2025-11-09

How does AnQiCMS handle and display the lazy loading (lazyload) feature of images in article content?

In website operation, the loading speed of image content is crucial for user experience and search engine optimization (SEO).Especially when an article contains a large number of images, if all the images are loaded all at once when the page loads, it may cause the page to respond slowly and even affect the user's patience.This problem solved, the image lazy loading (Lazyload) technology emerged.

2025-11-09

How to correctly display the filing number and copyright information at the bottom of the AnQiCMS website and ensure automatic year update?

Information at the bottom of the website, such as filing numbers and copyright statements, may seem trivial, but it is an important manifestation of the website's professionalism, legal compliance, and brand trust.For operators, correctly displaying this information and ensuring that the year can be automatically updated is not only convenient but also avoids the trouble of manual modification every year.In AnQiCMS, achieving this goal is very direct and flexible.

2025-11-09

How to flexibly call and display the value of the 'Content Model Custom Field' in the AnQiCMS frontend page?

AnQi CMS excels in content management, especially its flexible content model and custom field features, which greatly facilitates the construction of personalized websites for us.The content of a website is often not just the title and text, but we may also need various additional information such as the author of the article, the source of publication, product specifications, event location, and floor area.These custom fields are like a 'personal filing cabinet' for content, allowing us to tailor the required attributes for each content type according to business needs.

2025-11-09

How to set up an independent display layout and elements for the single page of AnQiCMS, such as the 'About Us' page?

In AnQiCMS, setting up an independent display layout and elements for single pages like "About Us" can make the website content more distinctive and professional.AnQiCMS with its flexible template engine and modular design makes this process intuitive and efficient.Why do you need a custom layout for a single page?

2025-11-09