When operating a website, we always hope to prioritize the most important and popular content for visitors, ensuring that the focus area of the website always presents the freshest and most attractive information.It takes time and is prone to errors to manually update this content.It is fortunate that Anqi CMS provides a very practical "Recommended Attributes" feature, allowing us to easily achieve flexible content display and automated management.
What is the 'Recommended Attributes' feature of Anqi CMS?
In simple terms, 'recommended attributes' are like applying special tags to your website content, telling the system where this content should be displayed or in what special way. The Anqi CMS provides eight preset recommended attributes, each with a corresponding letter identifier for easy use in front-end templates:
- Headline [h]: Suitable for the most important headline content on the website.
- Recommend [c]: Often used in columns such as 'Editor's Recommendations' and 'Featured Articles'.
- Slideshow [f][en] Specifically designed for carousel or spotlight images, used to display a set of images or news.
- [en] Recommended [a][en] : Indicates a special recommendation, which may have a higher priority than regular recommendations.
- [en] Scroll [s]适合用于新闻滚动条或公告。【en】
- 加粗 [b] 【en】[en] Emphasize the content title to make it more prominent in the list (although usually achieved through CSS, this property can be used as a filter criterion).
- [en] Image [p][en] Filter articles with important images for display in the photo/text area.
- [en] 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 one recommendation attribute.
How to set the 'recommendation attribute' of the content in the background?
Setting recommended attributes for content is very intuitive.When entering the Anqi CMS backend, whether publishing new articles, new products, or editing existing content, you can find an option named 'Recommended Properties' on the right or bottom of the editing interface.Here will be listed all the above properties, presented in the form of checkboxes.
Flexibly display specific content on the front-end page
After setting up the recommended attributes, the next key step is to use these attributes to filter and display content on the website's front end (i.e., the page the user sees). The template tag feature of Anqi CMS makes this process very simple, mainly througharchiveListlabel combined withflagparameters.
Assume we want to display the latest 5 articles with the 'Recommended [c]' attribute 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:
archiveListThis is the core tag used by AnQin CMS to retrieve content lists.featuredContentThis is the variable name we define for this content list group. You can name it as you like.type="list"This indicates that we are getting a fixed number of content items in a list, rather than a paginated list.flag="c"It is the key parameters that we filter with the 'recommended' attribute. If you want to display 'top' content, just setflag="c"toflag="h".limit="5"it limits to showing only 5 articles.order="id desc"Then let the content be sorted by publish ID in reverse order, usually meaning to display the most recently published.
By modifyingflagWe can easily switch to call different recommended content by the value of the parameter. For example, to implement a scrolling news ticker at the top of a website, you can useflag="s"If you need a picture carousel, useflag="f".
If a region does not want to display content with specific recommendation attributes, for example, if "headline" content has already been displayed elsewhere on your website and you want to avoid repetition, you can useexcludeFlagparameters. For example,excludeFlag="h"It will exclude all content marked as “Headline”.
Example of practical application scenarios
The flexibility of the “Recommended Attributes” feature allows it to meet various content display needs:
- Homepage featured images or carousel areasSelect the "Slide [f]" attribute for several important articles or activity images to be displayed in the background, and it is used in the front-end template
flag="f"Invoke, and set appropriatelimit[en]The number, so as to achieve dynamic focus map. - [en]Sidebar popular recommendationsYou can check 'Headline [h]' or 'Recommend [c]' for some popular articles, and then combine them in the sidebar.
order="views desc"(sorted by view count in reverse order) andflag="h"orflag="c"Show "Hot Headlines" or "Hot Recommendations" to attract visitors to click. - Content aggregation on the special topic pageOn a specific topic page, you can mark important content related to that 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 them collectively, making it convenient for visitors to browse.
- Featured products on the product display page[en]For e-commerce websites, you can check the 'Special Recommendation [a]' attribute for newly launched, hot-selling, or discounted products, and then display them at a specific location on the product list page.
flag="a"Display and highlight these featured products.
Summary
The 'Recommended Attributes' 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 operation.By making reasonable use of these recommended properties, we can easily achieve dynamic content updates and personalized display, making the website more vivid and attractive, thereby better serving our visitors and business goals.
Common Questions (FAQ)
1. Can I select multiple 'recommended attributes' at the same time in an article? Are there any limitations when calling in the frontend?Yes, when editing articles on the Anqi CMS backend, you can select multiple recommendation attributes for the same article.For example, an article can be both a 'headline' and a 'slideshow'.archiveListWhen calling the tag content, oneflagParameters can only specify one property letter at a time for filtering (for exampleflag="h"orflag="f"). This means you may need to use different ones in different content display areas.flagCall this article with multiple properties using the parameter.
2. If I have set recommended properties but they are not displayed on the front page, what could be the reason?If the recommended property is not displayed on the front end after it is set, please check the following points:
- Is the template code correct:Make sure you are using the correct
archiveListTags andflagparameters, such asflag="c". - Content status:Ensure that the content has been published and is not set as a draft