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