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

This feature helps us manage the display logic of content more finely, filtering out some important or special-purpose content from a massive amount of information and presenting it in the location where users are most likely to notice.

What is the content recommendation attribute (Flag)?

Content recommendation attribute, as the name suggests, is a kind of 'recommendation' tag applied to content.It transcends the traditional classification system, allowing us to mark based on the display priority of the content or for special purposes.For example, an important news article, in addition to belonging to the "Industry News" category, we may also want it to appear in the "Headline News" area on the homepage and the "Image Carousel" area.By setting the recommended properties, it can easily achieve such a requirement.

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

  • 头条[h]: Used to mark the most important news or article.
  • 推荐[c]As a general recommendation content, it is commonly found in areas such as 'Editor's Recommendations' in article lists.
  • 幻灯[f]Content specifically used to be displayed in the carousel or slide show area of the website.
  • 特荐[a]:通常指具有特殊推荐价值的内容,区别于普通推荐。
  • 滚动[s]:适合在公告栏或新闻跑马灯中滚动的简短信息。
  • 加粗[h]:通常用于在标题或列表中以加粗形式突出显示。
  • 图片[p]:标记为带有重要图片的文章,可以在图片展示区调用。
  • 跳转[j]This means that clicking it will jump to an external link or other specified page content.

What needs to be paid special attention to is,头条[h]and加粗[h]all use the same identification lettersh.In practical operation, it is recommended to make a judgment according to specific needs to avoid confusion and ensure the accuracy of the call. For example, if you need to mark both headline and bold at the same time, you may need to consider whether these two properties will appear simultaneously in the same list from a business logic perspective, or make a more detailed distinction when calling the template.

How to set recommended attributes for content in the background?

Mark content with recommended attributes, the operation is very intuitive.When you publish a new document or edit an existing document in the Aanqi CMS backend, you will see a section named 'Recommended Properties'.

  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'In the document editing page, on the left or right side, you will see the 'Recommended Properties' area.
  3. Select the recommended tagHere will be listed all available recommended properties, with a checkbox next to each property.You can select one or more properties for the current document as needed.头条[h]and幻灯[f].
  4. Save the 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.

Through 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 recommendation attributes in a frontend template?

Present the recommended content set up in the background on the website front-end, it requires the powerful template tag system of Anqi CMS, especiallyarchiveListLabel.archiveListThe tag is a universal tag for retrieving document lists, it supports various filtering conditions, including our "recommended attributes".

When usingarchiveListwhen using the tag, we can go throughflag参数来指定要调用的推荐属性字母。

一个基本的调用示例可能像这样:

{# 假设我们想在首页某个区域显示“推荐[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 namedrecommendedArticlesA variable to store the retrieved document list.
  • with flag="c":这是关键,它告诉系统只获取被标记为推荐[c]属性的文档。
  • limit="5":Limit to displaying 5 documents.
  • {% for item in recommendedArticles %}:Loop through the retrieved documents,itemrepresents each document.

If you wish to display somedoes not includeContent of specific recommendation attributes, such as displaying the latest articles, but excluding all '头条[h]' articles, you can useexcludeFlagParameters:

Display the latest 5 articles, but exclude all articles with the attribute '头条[h]'