How to use the “Recommended Attributes” feature of Anqi CMS to flexibly display specific content on the front page?

When operating a website, we always hope to prioritize the most important and popular content for visitors, so that the focus area of the website can always present the freshest and most attractive information.It takes time and is prone to errors to manually update this content. Fortunately, Anqi CMS provides a very practical "recommended attribute" function, which allows us to easily achieve flexible content display and automated management.

What is the 'Recommendation Attribute' feature of Anqi CMS?

In simple terms, 'recommended attributes' are like putting a special tag on your website content to tell the system where or how this content should be displayed. Anqi CMS provides us with eight preset recommended attributes, each with a corresponding letter identifier for easy use in front-end templates:

  • Headline [h]: Suitable for the most important headliner content on the website.
  • Recommend [c]: Often used in columns such as 'Editor's Recommendations' and 'Featured Articles'.
  • Slide [f]: Designed specifically for carousels or focus images, used to display a set of images or news.
  • Special recommendation [a]: Indicates a special recommendation, which may have a higher priority than ordinary recommendations.
  • Scroll [s]: Suitable for news scrolls or announcements.
  • Bold [b]: Emphasize content titles to make them more prominent in the list (although usually implemented through CSS, this attribute can be used as a filter criterion).
  • Image [p]: Filter articles with important images for display in the image and text area.
  • Jump [j]: If the content itself is an external link or a special jump, this attribute can be used to mark it.

These properties can be used individually, or multiple can be selected for the same document at the same time.However, it should be noted that when calling from the front end, each list area can usually only filter content based on a recommended attribute.

How to set the 'recommended attribute' of content in the background?

It is very intuitive to set recommended properties for content. When we enter the Anqi CMS backend, whether it is to publish new articles, new products, or edit existing content, we can find an option named "Recommended Properties" on the right or bottom of the editing interface.This will list all the properties and display them in check boxes.

You only need to check one or more corresponding properties based on the importance of the content or the way you want to display it.For example, an article you want to appear in the homepage slideshow carousel and is also an 'Editor's Pick', can check both 'Slideshow [f]' and 'Recommend [c]'.After saving, this content will be marked with the special tag you assign.

Display specific content flexibly on the front-end page

After setting up the recommended properties, the next key is to use these properties to filter and display content on the website front end (i.e., the page the user sees). The template tag feature of Anqi CMS makes this process very simple, mainly througharchiveListLabel collaborationflagParameter to achieve.

Suppose we want to display the latest 5 articles with the attribute "recommended [c]" on the homepage, we can write the code like this in the template file:

{# 在首页展示带有“推荐[c]”属性的最新文章 #}
<div class="featured-articles">
    <h2>编辑精选</h2>
    {% archiveList featuredContent with type="list" flag="c" limit="5" order="id desc" %}
        {% for item in featuredContent %}
            <div class="article-card">
                <a href="{{ item.Link }}">
                    <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="article-thumbnail">
                    <h3>{{ item.Title }}</h3>
                </a>
                <p class="article-description">{{ item.Description|truncatechars:100 }}</p>
            </div>
        {% empty %}
            <p>目前还没有推荐内容哦!</p>
        {% endfor %}
    {% endarchiveList %}
</div>

In this code block:

  • archiveListIt is the core tag used by AnQi CMS to get the content list.
  • featuredContentIt is the variable name we define for this content list, you can name it as needed.
  • type="list"The list of items retrieved is fixed, not requiring pagination.
  • flag="c"We select the key parameters with the "recommended" attribute. If you want to display "top" content, just need toflag="c"changed toflag="h".
  • limit="5"restricted to display only 5 articles.
  • order="id desc"Then let the content be sorted in descending order by the publishing ID, which usually means displaying the latest published.

By modifyingflagThe value of the parameter allows us to easily switch to calling different recommended attributes. For example, to implement a scrolling news bar at the top of a website, you can useflag="s"If you need a picture carousel, then useflag="f".

If a certain area does not want to display content with specific recommended attributes, such as if the "top story" content has already been displayed elsewhere on your website and you want to avoid repetition, you can useexcludeFlagthe parameters. For example,excludeFlag="h"Excludes all content marked as "Headline".

Example of practical application scenarios

The flexibility of the "Recommendation Attribute" feature makes it capable of meeting various content display needs:

  1. Homepage focus image or carousel areaSelect the 'Slide [f]' attribute for several important articles or activity images in the background, and use it in the front-end templateflag="f"Invoke and set appropriate parameterslimitThe quantity can realize dynamic focus pictures.
  2. Sidebar hot recommendationsYou can check the 'Top [h]' or 'Recommended [c]' for some popular articles and then combine them in the sidebar.order="views desc"(Sorted by views in descending order) andflag="h"orflag="c"to display 'Hot Headlines' or 'Hot Recommendations' to attract visitors to click.
  3. Special page content aggregationOn a special topic page, you can mark important content related to the topic with a specific recommendation attribute (for example, you can customize a special recommendation attribute if the system supports it, otherwise use a general attribute), and then display it centrally for visitors to browse conveniently.
  4. Featured products on the product display pageFor e-commerce websites, you can check the 'Special Recommendation [a]' attribute for newly launched, hot-selling, or discounted products, and then display them in a specific location on the product list page.flag="a"Display and highlight these featured products.

Summary

The 'Recommended Attribute' feature of AnQi CMS is an efficient and easy-to-use tool that closely integrates content management with front-end display, greatly enhancing the efficiency of website operations.By reasonably utilizing these recommended properties, we can easily achieve dynamic content updates and personalized displays, making the website more vivid and attractive, thereby better serving our visitors and business goals.


Frequently Asked Questions (FAQ)

1. Can I select multiple 'recommended attributes' at the same time in an article? What are the limitations when calling on the front end?Yes, when editing articles in the Anqi CMS backend, you can check multiple recommended properties for the same article.For example, an article can be either a "top story" or a "slide."}However, it is used on the front-end pagearchiveListWhen calling the label content, oneflagYou can only specify one attribute letter at a time for filtering (for exampleflag="h"orflag="f"This means that you may need to use different ones in different content display areas,flagCall this article with multiple attributes.

2. If I have set the recommended attribute but it does not display on the front page, what could be the reason?If the recommended property is not displayed on the front page after it is set, please check the following points:

  • Is the template code correct?Make sure you are using the correct one in the templatearchiveListTags andflagparameters, for exampleflag="c".
  • Content status:Make sure the content has been published and is not set to draft