In website content operation, displaying carefully selected high-quality content in an eye-catching manner is a key factor in improving user experience, guiding reading behavior, and achieving operational goals.AnQiCMS (AnQiCMS) fully understands this and provides a flexible and powerful "Recommended Attributes" feature, making content filtering and display simple and efficient.By setting different recommendation attributes for articles, we can accurately present specified types of content in various areas of the website, whether it's the headline news on the homepage or the stunning images in the carousel, it can be easily achieved.
Deeply understand the "Recommended Attributes" of AnQi CMS
The CMS allows us to assign one or more 'recommended attributes' to each article, which act like tags for content, used to identify their special display priority or type.When editing articles in the background, you will see a "Recommended Properties" option, which includes a variety of preset property tags.头条[h]Generally used for the most important news or announcements,幻灯[f]which is often used for image content that needs to be displayed in a large area.推荐[c]Can be used to mark high-quality articles. The alphabetical codes (such ash,f,c) are the key to filtering content in the template.
These properties are very intuitive to set, and you can flexibly select one or more properties based on the importance of the article or its expected display form on the page.For example, an article that is both a headline and needs to appear in the slide as an image can have both the 'Headline' and 'Slide' properties checked.
核心操作:利用 EnglisharchiveListTag filter content
In the template design of AnQi CMS,archiveListLabels are the core tools for filtering and displaying article content. They have rich parameters, allowing us to accurately obtain the required content based on various conditions. Among them,flagThe parameter is specifically used to identify and filter articles with specific recommendation properties.
When we need to call articles with specific recommendation properties in the template,archiveListThe basic usage of the label is like this:
{% archiveList archives with flag="h" limit="5" %}
{# 在这里循环显示文章内容 #}
{% endarchiveList %}
In this code block:
archivesThis is a variable name we define, used to store the list of filtered articles.flag="h"Indicates that the system should only filter out articles marked as "Headline".limit="5"It limits the maximum number of displayed articles to 5.
Exceptflag,moduleIdandcategoryIdParameters are often used in conjunction with recommendation properties to further filter recommended content under specific content models or specific categories.For example, you may only want to display "Top News" articles under the "News and Information
Sometimes, you may need to display all content except for some recommended properties. In this case,excludeFlagparameters come into play. For example,excludeFlag="h"Excludes all articles marked as "Top News", thus displaying other types of articles in a certain area.
Practice cases: diversified content display
Let's look at a few specific examples to see how to applyarchiveListTags and recommendation attributes, create different content display areas on the website.
1. Homepage headline news area
On the homepage of the website, there is usually an area dedicated to displaying the most important news. We can mark these articles in the background as头条[h]properties.
<div class="headline-news">
<h3>头条新闻</h3>
<ul>
{% archiveList topHeadlines with flag="h" moduleId="1" limit="5" order="id desc" %}
{% for item in topHeadlines %}
<li>
<a href="{{ item.Link }}" title="{{ item.Title }}">
<h4>{{ item.Title }}</h4>
<p>{{ item.Description|truncatechars:80 }}</p>
</a>
</li>
{% empty %}
<li>暂无头条新闻。</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
这段代码会从文章模型(English)moduleId="1") among them, sorted by the latest release (order="id desc"The order of operations, filter out up to 5 articles with the 'top news' attribute, and display their titles, links, and summaries.{% empty %}The label ensures that the page can display a friendly prompt message when there are no articles that meet the conditions.
2. Home page slideshow/carousel
The slide area usually requires a prominent large image and a concise title. We can mark the articles that need to be displayed in a carousel as幻灯[f]properties, and ensure that the cover image of the article has been uploaded.
<div class="main-carousel">
<ul class="slides">
{% archiveList carouselItems with flag="f" moduleId="1" limit="4" order="id desc" %}
{% for item in carouselItems %}
<li>
<a href="{{ item.Link }}" title="{{ item.Title }}">
{% if item.Logo %}
<img src="{{ item.Logo }}" alt="{{ item.Title }}" />
{% endif %}
<div class="carousel-caption">
<h3>{{ item.Title }}</h3>
</div>
</a>
</li>
{% empty %}
<li>暂无幻灯内容。</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
Here, we filtered 4 articles with the "slide" attribute and displayed their cover images (item.Logo) and titles. Please note,item.LogoEnglish translation: Typically used to get the cover image of an article, which is very practical for slide shows.
English translation: 3. Recommended article list (excluding headlines)
Sometimes, we may want to display 'More Recommendations' content at the bottom of a sidebar or content section, but do not want it to duplicate the 'Headlines' content on the homepage. In this case, you can useexcludeFlag.
<div class="recommended-articles">
<h3>更多推荐</h3>
<ul>
{% archiveList moreRecommendations with excludeFlag="h" moduleId="1" limit="6" order="views desc" %}
{% for item in moreRecommendations %}
<li>
<a href="{{ item.Link }}" title="{{ item.Title }}">
<img src="{{ item.Thumb }}" alt="{{ item.Title }}" />
<span>{{ item.Title }}</span>
</a>
</li>
{% empty %}
<li>暂无推荐文章。</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
This code will exclude all 'headline' articles from the article model and then display the 6 articles with the highest views,order="views desc"(other recommended articles), showing their thumbnailsitem.Thumband titles.
Content Display Strategy and **Practice
- Flexible Combination Usage:
flagThe parameter can accept a single or multiple recommended attributes, for exampleflag="c,f"Articles with both "recommended" and "slideshow" will be filtered out. You can achieve fine-grained content distribution by combining or using properties individually in different regions according to your actual needs. - The importance of backend management: Ensure that content editors can accurately and consistently set recommended properties when publishing or updating articles.Clear recommendations are essential for the correct and effective display of content by the front-end template.
- Optimize sorting and quantity: Other
flagUtilize appropriatelyorder(such asid descThe latest,views descMost popular,sort descManual sorting by backend) andlimitParameters, which can better control the presentation priority and quantity of content, avoiding information overload. - Enhance user experience: By precise content recommendation, it can effectively reduce the bounce rate of users, extend the time users spend on the website, and guide them to discover more interesting content.
- SEO-friendly: Reasonably highlight key content, which is also helpful for search engines to understand the core information of the website and improve the weight of important pages.
The "Recommended Features" function of AnQi CMS provides great convenience and flexibility for website content operations. By masteringarchiveListTags and theirflagThe application of parameters, you can easily handle the website content stream, allowing your high-quality content to reach users at the right time, in the right place, and in the right form.
Common Questions (FAQ)
Q1: Can an article be set with multiple recommendation attributes? If multiple are set, how does the template filter?
Yes, an article can have multiple recommendation attributes at the same time, for example, an article can be both 'Headline' and 'Slideshow'. In the template,archiveListTagsflagThe parameter can accept a single attribute (such asflag="h")or multiple attribute combinations(such asflag="h,f")。When you specifyflag="h,f"the system will filter out all items that contain the 'h' attributeorArticles containing the “f” attribute. If you only want to filter articles that contain all specified attributes, you need to implement it according to specific template engine features and custom logic, but usuallyflagThe parameter is a logical OR relationship.
Q2: Besides the recommended attributes, what other parameters can help me filter content more accurately?
ExceptflagRecommended attributes,archiveListThe label also provides multiple powerful filtering parameters. For example,moduleIdYou can specify which content model (such as article model, product model) to retrieve content from;categoryIdCan limit to only display content under specific categories;orderParameters can control the sorting method of content (such as by publishing time, views, or custom sorting by backend);limitThe parameter is used to control the number of displayed content. Flexible combination of these parameters can achieve very precise content filtering.
Q3: If there is no article that meets the recommended attributes in a certain area, what will the page display?
InarchiveListTagsforIn the loop, you can use them together.{% empty %}Tags to handle the case where there is no content. For example,{% for item in archives %} ... {% empty %} <li>暂无内容。</li> {% endfor %}). WhenarchivesThe list is empty, the system will render{% empty %}Ensure that the content within the tag does not result in blank or error, enhancing user experience.