How to display recommended attributes (such as headlines, recommendations, sliders) in article lists or detail pages?

Calendar 👁️ 66

In AnQi CMS, in order to make your website content more attractive and able to flexibly display articles of different importance levels or display forms, the system provides the "recommended attribute" feature.By cleverly utilizing these properties, you can easily tag content on article lists or detail pages with 'headline', 'recommended', 'slideshow', and other tags, thereby guiding users' attention and enhancing the effectiveness of content marketing.

This guide will take you in-depth to learn how to set and use these recommended properties in AnQiCMS, making your website content management more convenient.

Understand the recommended attributes and their functions

First, let's get to know these recommended properties.In the AnQiCMS backend, when you add or edit a document, you will see an option for 'Recommended Attributes'.

  • Headline [h]: Usually used for the most important and most concerned news or articles on the homepage, attracting the user's first glance.
  • Recommend [c]: Marked as high-quality, content worth reading, often appears in the sidebar, related recommendations area.
  • Slide [f]: Designed specifically for carousels, articles with this attribute will typically extract the cover image, and play in the large image display area in a loop.
  • Special recommendation [a]: Further than 'Recommended', usually selected in-depth content by the editor.
  • Scroll [s]: Suitable for notifications, announcements, and other information that needs to be displayed scrolling in a specific area.
  • Image [p]: Emphasize content primarily with images, or highlight images when displaying in a list.
  • Jump [j]When the article is clicked, it does not enter the article detail page but directly jumps to the preset external link, which is very suitable for advertising or referencing external resources.

The essence of these properties is to label your content with different types of "tags", convenient for you to filter and display on the front-end page according to your needs.A content can have multiple recommended attributes at the same time, for example, an article can be both a 'headline' and a 'slider', which means it can be displayed in the headline area as well as part of the carousel.

Two, set the recommendation attributes of the content in the background

The recommended property is very intuitive.When you log in to the AnQiCMS backend, go to the 'Content Management' module, select 'Add Document' or edit an existing document, you will see the 'Recommended Attributes' section.

You just need to check the corresponding properties.For example, if you want a newly published article to be the headline news on the homepage and also displayed in the carousel, you can check both 'Headline[h]' and 'Slide[f]'.The system will automatically apply these tags to this content after you save the article.

Three, display and filter the recommendation attributes content on the article list page

On the front end of the website, the article list page is an important window for displaying content. AnQiCMS provides flexible template tagsarchiveList, allowing you to filter and display content based on recommended attributes.

1. Filter the list of recommended attributes

Suppose you want to display "Top Stories" articles in a special area on the homepage or show "Recommended" content in the sidebar, you can do it this way:

{# 假设您想获取5篇头条文章 #}
<div class="headline-articles">
    <h2>头条新闻</h2>
    <ul>
        {% archiveList archives with type="list" flag="h" limit="5" %}
            {% for item in archives %}
                <li>
                    <a href="{{item.Link}}">{{item.Title}}</a>
                    {# 这里可以根据需要添加发布时间、简介等信息 #}
                    <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                </li>
            {% empty %}
                <li>目前没有头条文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

{# 假设您想在侧边栏展示3篇推荐文章 #}
<div class="recommended-articles">
    <h3>推荐阅读</h3>
    <ul>
        {% archiveList recommendations with type="list" flag="c" limit="3" %}
            {% for item in recommendations %}
                <li><a href="{{item.Link}}">{{item.Title}}</a></li>
            {% empty %}
                <li>暂无推荐文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In the code above,flag="h"Used to filter articles with the "Headline" attribute, andflag="c"then used to filter articles with the "Recommended" attribute. You just need to replaceflagthe value of the parameter with the corresponding attribute letter (such asfrepresenting slides,jRepresent jump and so on), you can get the list of articles with different properties.

2. Directly display the recommended attribute tags in the list items.

In addition to filtering, you may also want to add an eye-catching icon or text mark to articles with specific recommended attributes in the normal article list, so that users can recognize them at a glance. At this point, we need toarchiveListinside the loop, usingitem.FlagField to judge.

item.FlagIt will return a string containing all the recommended attribute letters set in the article. We can usecontaina filter to check if it contains specific attribute letters.

<div class="all-articles-with-badges">
    <h2>全部文章</h2>
    <ul>
        {% archiveList articles with type="list" limit="10" showFlag=true %}
            {% for item in articles %}
                <li>
                    <a href="{{item.Link}}">
                        {% if item.Flag|contain:"h" %}
                            <span class="badge headline-badge">头条</span>
                        {% elif item.Flag|contain:"c" %}
                            <span class="badge recommended-badge">推荐</span>
                        {% elif item.Flag|contain:"f" %}
                            <span class="badge slideshow-badge">幻灯</span>
                        {% endif %}
                        {{item.Title}}
                    </a>
                </li>
            {% empty %}
                <li>暂无文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Please note that to obtainitem.Flagyou need toarchiveListthe tag withshowFlag=trueParameter.

In this way, each item in the article list will dynamically display the corresponding tag based on its recommended attributes, greatly enhancing the readability and visual appeal of the content. Of course, you will also need some CSS styles to beautify thesebadge.

Four, display recommended property tags on the article detail page

On the article detail page, you can also display corresponding tags or information based on the recommended properties of the current article. This is similar to the logic on the list page, but we use it directly.archiveThe object representing the current article'sFlagfield.

<article class="article-detail">
    <h1>{{archive.Title}}</h1>
    <div class="article-meta">
        发布时间:{{stampToDate(archive.CreatedTime, "2006年01月02日")}}
        {% if archive.Flag|contain:"h" %}
            <span class="badge detail-headline">头条新闻</span>
        {% endif %}
        {% if archive.Flag|contain:"c" %}
            <span class="badge detail-recommended">小编推荐</span>
        {% endif %}
        {% if archive.Flag|contain:"j" %}
            <span class="badge detail-jump">(点击此文将跳转到外部链接)</span>
        {% endif %}
        {# 您可以在这里继续添加其他属性的判断 #}
    </div>
    <div class="article-content">
        {{archive.Content|safe}}
    </div>
</article>

Here, we use{{archive.Flag|contain:"h"}}To determine whether the current article contains the 'Headline' attribute and display the 'Headline News' marker accordingly.Even if the user enters the detail page, they can clearly know the importance or particularity of this content.

5. Practical

Related articles

How to set up the website to display specific notification information on the front end when it is in "closed site" status?

The website will always encounter times when it needs to be maintained, upgraded, or temporarily adjusted.At this moment, it is crucial for users to see a friendly and clear prompt instead of a cold error page, which is vital for the image and user experience of the website.Fortunately, AnQiCMS provides a very convenient and flexible "shutdown" function, allowing you to easily manage the maintenance status of the website and display customized notification information to front-end visitors.Next, let's take a look at how to set the "shutdown" status of the website in the AnQiCMS backend

2025-11-08

How to batch regenerate all content thumbnails to fit the new frontend display size?

When the visual style of a website needs a complete overhaul, or to adapt to the ever-changing size of device displays, we often need to adjust the size of image thumbnails.AnQiCMS (AnQiCMS) fully understands this and provides a convenient and efficient solution for such needs.How to batch regenerate thumbnails for all content in response to adjustments in front-end display dimensions to ensure the aesthetic beauty and loading efficiency of the website, which is a concern for many operators.Why do you need to regenerate the thumbnail? Thumbnails play a crucial role in website operations

2025-11-08

How to implement automatic conversion of uploaded images to WebP format to optimize front-end loading and display speed?

In today's content operation, website loading speed is crucial for user experience and search engine rankings.Images are an important part of web content, and their loading performance is often a key factor affecting overall speed.AnQiCMS (AnQiCMS) is well aware of this and provides a convenient image optimization feature, especially converting images uploaded to WebP format automatically, which can significantly improve the display speed of the website's front-end.### WebP format: A speed booster for front-end loading WebP is an image format developed by Google

2025-11-08

How to remove spaces or specified characters from the beginning, end, or all positions of a string and then display it?

In website content operation, we often encounter situations where strings contain unnecessary spaces or specific characters.These seemingly minor issues may affect the display aesthetics, SEO effects, and user experience of the content.For example, a product title may display differently on different devices due to leading and trailing spaces, or a keyword list may be surrounded by additional symbols, affecting search engine recognition.

2025-11-08

How to display a custom Banner image group on the category page or single page?

It is crucial that visual content is attractive in website operation.Especially for category pages and standalone single pages, displaying a set of carefully designed banner images can effectively attract visitors' attention, strengthen the brand image, and convey specific information.AnQiCMS provides a straightforward and flexible mechanism that allows you to easily configure and display custom Banner image groups on these key pages.

2025-11-08

How to display the view count of articles in the article list or detail page?

In website operation, the number of article views is a very intuitive and important indicator, which not only reflects the popularity of the content but also provides data support for the optimization of subsequent content strategies.For websites built using AnQiCMS, displaying the number of views on article lists or detail pages is a relatively simple operation. With the powerful template tag features provided by AnQiCMS, we can easily achieve this requirement.Understanding the "Page Views" feature of AnQiCMS AnQiCMS is built with powerful traffic statistics functionality

2025-11-08

How to remove empty lines generated by conditional judgment or loop tags in the template to optimize the display cleanliness of the page source code?

In website operation, we all hope that the website is not only powerful in function, rich in content, but also the source code behind it should be neat and orderly.However, when developing with a flexible template system like AnQiCMS, you may sometimes find that the generated HTML source code contains many blank lines, which are mainly caused by conditional judgment or loop tags in the template.Although these blank lines usually do not have a substantial impact on the functionality of the website, they do indeed reduce the readability of the source code, and bring inconvenience to subsequent maintenance and debugging.

2025-11-08

How to render Markdown content into HTML in AnQiCMS?

In a content management system, Markdown is a lightweight markup language that allows content creators to write in plain text and format it with simple symbols, which can then be easily converted into structured HTML.For AnQiCMS users, using Markdown to write content not only improves efficiency but also ensures consistency and maintainability of content formatting.

2025-11-08