How to add recommended attributes to AnQiCMS documents to affect the display sorting order on the front page list and detail pages?

Calendar 👁️ 67

In AnQi CMS, the recommended attribute is a very practical feature in content operation.It can help us classify and tag content, thereby affecting how these contents are displayed on the front page list or detail page, such as highlighting, prioritizing sorting, and even changing their layout styles.Understand and make good use of these properties, which will make your website content management more flexible and efficient.

One, set the recommended properties for the document in the background

To add recommended properties to the document, you first need to enter the Anqi CMS backend management interface

  1. Enter the document editing pageNavigate to the 'Content Management' menu, select 'Document Management', then choose an existing document to 'edit', or click 'Add New Document' to create a new document.
  2. Find the recommended property optionOn the left or right side of the document editing page (depending on your backend layout), you will see a section named "Recommended Properties."
  3. Select the recommended property: Anqi CMS provides eight preset recommendation attributes, each with a corresponding letter code for easy use in templates:
    • Headline[h]: It is usually used to mark the most important articles that need to be highlighted.
    • Recommended[c]: Marked as general recommendation content.
    • Slide[f]: Suitable for content that needs to be displayed on slides or in carousels.
    • Featured[a]: Special recommendation, more important than regular recommendations.
    • Scrolling[s]: Suitable for displaying in scrolling news or announcement areas.
    • Bold[h]This property name overlaps with 'Headline' in the document, the actual effect may need to be checked in the template implementation, but it usually indicates that the text in a list item needs to be bold.
    • Image[p]This may mean that the content needs to be displayed with an image.
    • Jump[j]This is usually used for content that needs to jump to an external link or a specific page.

You can select one or more recommended properties for the document based on its actual importance and the desired display effect.These properties are like 'content tags' attached to documents, making it convenient for the front-end template to filter and display according to these tags.

Second, use recommended attributes in the front-end template to affect display and sorting

After setting up the recommended properties, the next step is to use these properties to control the display of content on the front-end template. This is mainly achieved through the template tags of Anqi CMS.archiveListandarchiveDetailto achieve.

1. Call content with specific recommendation attributes

You can use it on the list page,archiveListlabel'sflagParameters to filter and call documents with specific recommended properties. For example, if you want to display the latest 5 "headlines" articles on the homepage:

{% archiveList featuredArticles with flag="h" order="id desc" limit="5" %}
    {% for item in featuredArticles %}
        <div class="headline-item">
            <a href="{{ item.Link }}">{{ item.Title }}</a>
            <p>{{ item.Description }}</p>
        </div>
    {% empty %}
        <p>暂无头条文章。</p>
    {% endfor %}
{% endarchiveList %}

This code will filter out all documents marked ash(Top News) documents, sorted by publication time (id desc) and display the latest 5 articles. You can modify them as neededflagParameter value, for exampleflag="c"Get recommended articles,flag="f"Get the slide article. If you need to get a document with multiple properties at the same time, you can directly combine the property letters, such asflag="hc".

2. Affects the display sorting of the list page

To make documents with recommended attributes display in a more prominent position on the list page, there are several common strategies:

  • Segmented query and combined displayThis is the most commonly used and flexible method. You can first query and display documents with specific recommendation attributes (such as "Top Story" or "Special Recommendation"), and then query and display the remaining documents.For example, first show 3 recommended articles, and then show the rest of the latest articles:

    <div class="special-recommendations">
        <h3>特荐内容</h3>
        {% archiveList specialRecs with flag="a" order="id desc" limit="3" %}
            {% for item in specialRecs %}
                <p><a href="{{ item.Link }}">{{ item.Title }}</a></p>
            {% endfor %}
        {% endarchiveList %}
    </div>
    
    <div class="latest-articles">
        <h3>最新文章</h3>
        {% archiveList latestArticles with excludeFlag="a" order="id desc" limit="10" %} {# 排除已特荐的,防止重复 #}
            {% for item in latestArticles %}
                <p><a href="{{ item.Link }}">{{ item.Title }}</a></p>
            {% endfor %}
        {% endarchiveList %}
    </div>
    

    ByexcludeFlagThe parameter allows you to avoid displaying the recommended content repeatedly in the subsequent regular list, thus ensuring the diversity of content.

  • UtilizeorderParameters are sorted.:archiveListlabel'sorderThe parameter allows you to specify the sorting method of the document. In addition,id desc(Sorted by ID in descending order, i.e., the most recent one) andviews desc(Sorted by views in descending order), and there is also anothersort desc(Sorted according to the backend custom sort) options. If your document backend supports setting a "sort value" (usually a

Related articles

How does AnQiCMS achieve adaptive display for PC and mobile pages?

In today's era of coexistence of multiple devices, whether a website can present a good user experience on different screen sizes is directly related to its influence and commercial value.Whichever device the user accesses, whether it is a desktop computer, laptop, tablet, or smartphone, they all expect to see a page with clear layout and easy operation.AnQiCMS (AnQiCMS) is well aware of this core requirement and therefore integrated a variety of flexible adaptive display strategies from the outset to ensure that your website can be presented in **status** on any device.AnQi CMS provides three main website display modes

2025-11-07

How to include common header and footer code snippets in AnQiCMS templates?

It is crucial to maintain consistent page layout, improve development efficiency, and reduce maintenance costs in website construction and content management.AnQiCMS as an efficient content management system provides a flexible template mechanism, allowing us to easily reuse common code snippets across different pages, such as the website header navigation, footer information, or sidebar, etc.This article will delve into how to elegantly introduce common header and footer code snippets in the AnQiCMS template, helping you better organize template files and improve the overall maintenance efficiency and user experience of the website.

2025-11-07

How to use AnQiCMS built-in tags to retrieve and display system configuration information (such as website name, Logo)?

It is crucial to maintain consistency and ease of updates in website operation and management.AnQiCMS as an efficient content management system fully considers this point, providing powerful built-in tag functions, allowing the global configuration information of the website (such as website name, Logo, filing number, etc.) to be easily dynamically obtained and displayed in the front-end template.This means you do not need to hardcode, just make a change in one place in the background, and all pages referencing this information will update automatically, greatly enhancing the maintainability and operational efficiency of the website.

2025-11-07

How does AnQiCMS improve website page loading speed and display experience through static caching?

In the digital age, the loading speed of websites has become a key indicator of user experience and search engine rankings.A website that responds quickly can effectively enhance user satisfaction, reduce the bounce rate, and bring better exposure to the content.AnQiCMS is a content management system focused on high performance and efficiency, and the static caching mechanism plays a crucial role in improving website loading speed.

2025-11-07

How to automatically extract document content to generate a summary or thumbnail for list display in AnQiCMS?

How to present content in a list page in an attractive way while not requiring a lot of manual work in website operation?This is often a problem that troubles operators. AnQiCMS understands this pain point and provides us with a set of effective solutions through its powerful automation features, especially excelling in the automatic generation and application of document summaries and thumbnails.### Automatically extract document summaries, say goodbye to manual writing Imagine that after each article is published, you need to manually write a concise summary, what a time-consuming task that is

2025-11-07

How to use the AnQiCMS Tag feature to associate and display related documents?

In today's increasingly complex content management, how to efficiently organize and present website content, allowing users to easily find the information they are interested in, while also improving the website's search engine performance, is a problem that every website operator is thinking about.AnQiCMS provides a series of powerful features to meet these challenges, among which, the Tag feature is undoubtedly a great tool for connecting and enriching content relationships.Tag, in the literal sense, is like various small tags attached to articles or products, which can cross traditional classification boundaries and bring together topics with the same theme

2025-11-07

How to flexibly display custom content model fields on the front page of AnQiCMS?

In the world of content management, flexibility is the key to website success.Most of the time, we find that the standard "article" or "product" content model cannot fully meet our unique business needs, such as the need to add unique attributes such as "material", "size", etc. for a specific type of product, or to add information such as "registration deadline", "event location", etc. to the activity detail page.At this moment, the powerful custom content model function of AnQiCMS can fully show its strength.

2025-11-07

How to ensure that the encoding of AnQiCMS template files is correct to avoid page garbled characters?

When using AnQiCMS to build a website, we may encounter abnormal display of pages, with garbled characters.This is usually due to incorrect encoding settings in the template file.Ensure that the template file uses the correct encoding is a key step to avoid such problems, ensure the normal operation of the website, and provide a good user experience.AnQiCMS as a modern content management system, its internal processing and recommendation standards tend to use UTF-8 encoding.UTF-8 is an international character encoding that can be compatible with the characters of most languages in the world, including Chinese

2025-11-07