AnQiCMS: Make good use of the "Flag" attribute to accurately control the layout of the website content
In content operation, merely publishing articles is not enough.How to make important content stand out, how to intelligently display specific content in different areas of the website, is the key to improving user experience and operational efficiency.AnQiCMS (AnQiCMS) is well-versed in this, providing us with a powerful and flexible tool - the 'Flag' attribute, to cleverly achieve this goal.
What is the "Flag" attribute of the content?
In simple terms, the "Flag" attribute is like tagging each of your documents with one or more special tags, but these tags are not ordinary categories or keywords.They are predefined, meaningful identifiers used to inform AnQiCMS where this content should appear in special areas of the website.By checking these properties while editing content in the background, we can easily control how content is displayed on the frontend page.
AnQiCMS has built-in 8 commonly used "Flag" attributes, which can be flexibly selected according to the importance of the content, display form, or special purpose:
- Headline
[h]This is usually used in the most prominent position on the homepage, emphasizing news or important announcements. - Recommended
[c]This indicates that the content has been carefully selected and is worth recommending to users, often used on list pages or sidebars. - Slide
[f]:Applicable to carousel or image wall, attracting users visually. - Featured
[a]:A step further than 'recommend', usually referring to valuable or exclusive in-depth content. - Scrolling
[s]: Suitable for display in news tickers or scrolling bulletin boards to maintain the dynamic visibility of content. - Bold
[h]This may look similar to the characters of 'Top Story', but in some designs, it may only be used to highlight text, not position. In actual applications, AnQiCMS will[h]Explained as the headline. - Image
[p]Emphasize content mainly with images, or need special processing of their thumbnail display. - Jump
[j]: Indicating that the user will be redirected to an external link or another specified page within the site after clicking on this content, rather than the content detail page.
You can check one or more of these properties when publishing or editing documents, AnQiCMS will record them and wait for you to call them in the front-end template.
Set the 'Flag' attribute in the background
The operation to set the "Flag" attribute for content is very intuitive.When you enter the AnQiCMS backend, whether it is 'Add Document' or 'Edit Document', among the many options in the document editing interface, you will see a section named 'Recommended Properties'.
Here, these 8 Flag properties are presented in the form of checkboxes.You can select one or more suitable properties based on the current document's operation strategy.For example, you may check both 'Headline' and 'Recommendation' for a very important press release;And a product that needs to be displayed in a large image carousel will check the 'Slide' attribute.After making a selection, save the document.
Use the 'Flag' attribute in the front-end template to control display
The power of the "Flag" attribute lies in how it seamlessly integrates with AnQiCMS template tags to achieve dynamic content display. The most commonly used tag isarchiveListIt can help us flexibly call different attribute content at any location on the website.
1. Call the content of the specific "Flag" attribute.
If you want to display only the articles marked as 'Top News' in a certain area of the website, such as the 'Top News' section on the homepage, you can use it like thisarchiveListTags:
{# 获取所有被标记为“头条”的文章列表 #}
{% archiveList archives with type="list" flag="h" limit="5" %}
{% for item in archives %}
<h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
<p>{{item.Description}}</p>
{% endfor %}
{% endarchiveList %}
here,flag="h"Make it clear to AnQiCMS to only crawl those that have been checked for the 'Top' attribute (correspondingh) of the document.limit="5"It limited the display quantity to 5 articles.
Similarly, if you want to display 'Recommended Products', you canflagis set toc:
{# 获取所有被标记为“推荐”的产品列表 #}
{% archiveList recommendedProducts with type="list" moduleId="2" flag="c" limit="4" %}
{% for item in recommendedProducts %}
<img src="{{item.Thumb}}" alt="{{item.Title}}" />
<h4><a href="{{item.Link}}">{{item.Title}}</a></h4>
{% endfor %}
{% endarchiveList %}
Please note that when you call content in the samearchiveListtag, you can only specify oneflagFilter properties. If you need to display the content of multiple properties at the same time, you need to use differentarchiveListtags to call.
2. Exclude the content of specific "Flag" properties.
Sometimes, we may need to display all the articles under a category, but exclude those that have already been displayed as 'headlines' to avoid repetition. At this time,excludeFlagParameters come into play:
{# 显示分类ID为1的所有文章,但排除掉“头条”文章 #}
{% archiveList normalArticles with type="list" categoryId="1" excludeFlag="h" limit="10" %}
{% for item in normalArticles %}
<li><a href="{{item.Link}}">{{item.Title}}</a></li>
{% endfor %}
{% endarchiveList %}
This ensures that the 'Top News' section and the regular article list will not have the same articles, optimizing the content layout.
3. Display the "Flag" property in list items
In addition to filtering content, you may also want to display the 'Flag' attribute next to each item in the content list, such as adding a 'recommend' word or an icon to 'recommended' articles. This can be done byshowFlagParameters and{{item.Flag}}to achieve:
{# 获取所有文章,并显示它们的Flag属性 #}
{% archiveList allArticles with type="list" showFlag=true limit="8" %}
{% for item in allArticles %}
<li>
{% if item.Flag %}
<span class="flag-badge">{{item.Flag}}</span> {# 假设item.Flag会返回属性的字母代码,如"h", "c" #}
{% endif %}
<a href="{{item.Link}}">{{item.Title}}</a>
</li>
{% endfor %}
{% endarchiveList %}
ByshowFlag=true,AnQiCMS will fill the Flag attribute value of the document toitem.Flagwhere you can style or display text based on these letter codes on the front end.
Application scenarios in practice
The "Flag" attribute brings great convenience and flexibility to our content operation:
- Home focus area: Pass
flag="f"Call slide content. - Sidebar hot recommendations: Pass
flag="c"Call recommended articles or products. - Display of lists in different stylesFor example, on the article list page, you may want to display 'Recommended' articles in large image mode, while other articles are displayed in small image or plain text mode, in which case you can call different
flagApply different styles and content. - Avoid confusion in content management.Top content without modifying categories or manually adjusting sorting, just a simple checkbox is needed.
Summary
The "Flag" attribute of AnQiCMS provides a powerful and flexible tool for content operators, allowing content management to go beyond traditional categories and tags.By simply checking the background and calling the front-end template, we can accurately control the display location and style of the website content, greatly enhancing the efficiency of content operation, and also bringing users a higher quality and more guiding browsing experience.Make good use of the "Flag" attribute to make your website content layout more intelligent and efficient.
Frequently Asked Questions (FAQ)
1. Can I call multiple "Flag" properties in a tag at the same time? For example, do I want to display both "Headline" and "Recommend"?archiveList标签中同时调用多个“Flag”属性的内容吗?比如,既想显示“头条”又想显示“推荐”?
No. AnQiCMS'sarchiveListThe tag is inflagThe parameter can specify only one "Flag" property at a time (for exampleflag="h"orflag="c"). If you need to display the content of multiple properties at the same time, you need to use multiple archiveListCall them and then combine them together.
2. What is the difference between the 'Flag' attribute and the ordinary 'Tag tag'?
The "Flag" attribute is a preset of AnQiCMS, mainly used to control the content in specific areas of the website (such as the homepage spotlight, sidebar recommendations, etc.)Display priority and display formThey are system-level content identifiers, usually consisting of a single letter code. The "Tag" label, on the other hand, is created freely by users, focusing more on the content'skeyword summary and associationUsed for topic aggregation and in-site search, it usually generates an independent tag list page.
3. What if I set a 'slide' attribute for a document but the front-end does not call the slide area, what impact will it have?
No negative impact. If you have set a certain "Flag" attribute in the background, but there is no corresponding one in the frontend template.archiveListTo call the content of this attribute, this document is just an internal tag, which will not be specially handled on the front end. It will still be displayed normally in the list under its category, or be displayed by other elements without tagsflagThe parameter'sarchiveListTag calling.