As a senior CMS website operation personnel for a security company, I know how to attract and retain users through precise content display.In AnQi CMS, 'Recommended Attribute' is an extremely useful feature that allows us to make refined tags on the content, thus enabling flexible calls and displays on the website frontend.Below, I will elaborate on how to call these recommended properties in front-end templates.
The backend management system of AnQi CMS provides the core feature of "Recommended Attributes", which is located on the editing page of documents (or other content models).Here, you can specify up to eight different recommendation attributes for each content to enable differentiated display on the front end.[h]、Recommended[c]、Slide[f]、Special Recommendation[a]、Scrolling[s]and bolding[h](Note: Here is the[h]with the headlines of[h]The code is the same, usually the priority of the headline is higher)、images[p]和 jump[j].Each attribute corresponds to a single-letter code. After you check the corresponding attribute in the background, the CMS will mark the content with the corresponding label. These labels are the basis for calling content in the front-end template.By reasonably setting these properties, we can effectively highlight important content and guide users' attention.
Calling these recommended content in the front-end template mainly depends on the Anqi CMS providedarchiveListLabel. This powerful label allows us to filter and display content lists based on various conditions. To call content with specific recommendation attributes, we need to usearchiveListthe label.flagParameters, and use the single-letter code of the recommended attribute as its value. For example, if you want to display articles marked as "recommended" in an area,[c]you can use it in the template.flag="c"This parameter tells the CMS to only return content items with the specified recommendation attributes.
The following is an example code for calling a list of recommended articles.
<div class="recommended-articles">
<h2>精选推荐</h2>
<ul>
{% archiveList recommendedArchives with type="list" flag="c" limit="5" %}
{% for item in recommendedArchives %}
<li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% empty %}
<li>暂无精选推荐文章</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
In this code,archiveListLabels are used to get content lists.type="list"The type of the list is specified,flag="c"then it precisely filtered out the articles marked as “Recommended”,limit="5"and limited the number of displayed articles to 5.forcyclically traversing the returneditem,and output the article title and link. If there are no articles that meet the criteria,emptythe content within the block will be displayed.
It is worth noting that the Anqi CMS.flagthe design principle of parameters is that each timearchiveList调用只能筛选一个推荐属性。这意味着,如果您需要在页面的不同区域分别展示“头条”内容和“幻灯”内容,您需要使用独立的archiveListLabel. Each label will be configured with its uniqueflagparameters to ensure that the content is displayed as expected. This design ensures the clear division and management of content blocks, avoiding content confusion.
Below is an example of how to create multiple recommendation content blocks.
<div class="headline-section">
<h3>最新头条</h3>
{% archiveList headlines with type="list" flag="h" limit="1" %}
{% for item in headlines %}
<p><a href="{{ item.Link }}">{{ item.Title }}</a></p>
{% empty %}
<p>暂无头条内容</p>
{% endfor %}
{% endarchiveList %}
</div>
<div class="slideshow-items">
<h3>精彩幻灯</h3>
<ul>
{% archiveList slideshows with type="list" flag="f" limit="3" %}
{% for item in slideshows %}
<li><img src="{{ item.Thumb }}" alt="{{ item.Title }}"><a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% empty %}
<li>暂无幻灯内容</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
In addition toflagparameter content filtering,archiveListthe tag also provides,excludeFlagandshowFlagparameters to achieve finer control.excludeFlagParameter allows you to exclude content with specific recommendation properties when getting the content list. For example,excludeFlag="h"it will return all content but exclude items marked as "top news".showFlag=trueThe returned content items can include all recommended attribute codes marked by them (such ashcf), and you can use them in the template.{{item.Flag}}To retrieve and display as needed. This is very useful for scenarios where you want to display 'Top Story' or 'Recommended' tags next to the title.
As a website operator, we should make full use of these recommended attributes to optimize user experience and content marketing strategies.Mark the most important articles as "Headlines" and place them in prominent positions, label visually appealing content as "Sliders" for carousel display, or mark specific products as "Recommended" to guide purchasing intentions.The recommended attribute for regularly checking and updating content to ensure that the website front-end always displays the latest and most relevant key information.