In website content operation, we often need to highlight certain specific content, such as the headline news on the homepage, special recommendations on product pages, or the focus content on the carousel. To display these contents flexibly in the specific area of the website front page, Anqi CMS provides a very practical feature: Content recommendation attribute (Flag).

This feature can help us manage the display logic of content more finely, filtering out some important or content with special purposes from a massive amount of information and presenting it in the place where users are most likely to notice.

What is the content recommendation attribute (Flag)?

Content recommendation attribute, as the name implies, is a kind of "recommendation" tag applied to content.It transcends traditional classification systems, allowing us to mark content based on display priority or special purposes.For example, an important news article, in addition to belonging to the "industry dynamics" category, we may also want it to appear in the "top news" area on the homepage and the "image carousel" area.By setting the recommended properties, it can easily achieve such a requirement.

AnQi CMS has preset eight types of recommendation attributes for us to choose from:

  • 头条[h]: Used to mark the most important news or articles.
  • 推荐[c]: As a general recommendation content, commonly found in areas such as 'Editor's Recommendation' in article lists.
  • 幻灯[f]: Specifically used for displaying content in the carousel or slideshow area of a website.
  • 特荐[a]: Generally refers to content with special recommendation value, different from ordinary recommendation.
  • 滚动[s]: Suitable for short messages rolling on bulletin boards or news ticker.
  • 加粗[h]This is usually used to highlight in bold in titles or lists.
  • 图片[p]This is marked as an article with an important image, which can be called in the image display area.
  • 跳转[j]This means that clicking will jump to an external link or another specified page content.

Pay special attention to this,头条[h]and加粗[h]all used the same identification letters.hIn practice, to avoid confusion and ensure accuracy, it is recommended to make judgments according to specific needs when setting content, for example, if you need to mark headlines and bold at the same time, you may need to consider whether these two attributes will appear simultaneously in the same list in terms of business logic, or make more refined distinctions when calling templates.

How to set recommended attributes for content in the background?

Apply recommended attributes to the content, making it very intuitive. When you publish a new document or edit an existing document in the Anqi CMS backend, you will see an option area named "Recommended Attributes".

  1. Enter the content editing interfaceIn the background navigation, find 'Content Management', select 'Publish Document' or 'Document Management' and click 'Edit' an existing document.
  2. Locate 'Recommended Properties'On the left or right side of the document editing page, you will see the "Recommended Properties" area.
  3. Select recommended tagsHere, all available recommended attributes will be listed, with a checkbox next to each attribute.You can select one or more properties for the current document as needed.For example, if a document is both the headline on the homepage and suitable for display as a carousel, you can check them at the same time头条[h]and幻灯[f].
  4. Save documentAfter selecting, remember to click the 'Submit' or 'Save' button at the bottom of the page to ensure that the recommended property settings take effect.

By making such settings, we have successfully tagged the content, and the next step is how to display these contents on the website front-end.

How to call content with recommended attributes in a frontend template?

Display the recommended content set up on the backend on the website front end, requiring the powerful template tag system of Anqi CMS, especiallyarchiveList.archiveListThe tag is a universal tag used to obtain a document list, it supports various filtering conditions, including our 'recommended attributes'.

While usingarchiveListWhen using the tag, we can go throughflagSpecify the recommendation attribute letter to be called.

A basic call example might look like this:

{# 假设我们想在首页某个区域显示“推荐[c]”属性的文章列表,显示5条 #}
<div class="recommended-section">
    <h3>编辑推荐</h3>
    <ul>
        {% archiveList recommendedArticles with flag="c" limit="5" %}
            {% for item in recommendedArticles %}
                <li>
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                    {# 这里可以根据需要添加更多内容,比如发布日期、缩略图等 #}
                    <span>发布于:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                </li>
            {% empty %}
                <p>暂无推荐内容。</p>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In this example:

  • archiveList recommendedArticles: Defined a namedrecommendedArticlesThe variable is used to store the document list obtained.
  • with flag="c": This is critical, it tells the system to only get the ones marked as推荐[c]The property document.
  • limit="5": Limit to display only 5 documents.
  • {% for item in recommendedArticles %}: Loop through the obtained documents,itemRepresents each document.

If you want to display someDo not includeContent of specific recommended attribute, such as displaying the latest articles, but excluding all "headline[h]" articles, you can useexcludeFlagparameters:

`twig {# Display the latest 5 articles but exclude all articles with the "Top [h]" attribute