How to use the recommendation attribute (Flag) of Anqi CMS to display featured content on the homepage or special page?

AnQi CMS provides an efficient way to manage and highlight important content on your website, that is through the document's 'recommended attributes' (Flag).This feature allows you to easily display carefully selected content on the homepage, special pages, or other key positions, thereby guiding visitors to pay attention and enhancing the interactivity and information delivery efficiency of the website.

Background settings for recommendation attribute: the first step to content selection

In the Anqi CMS backend, the starting point of managing content is to publish or edit documents.When you are ready with high-quality content that you want to stand out at critical positions on the website, the recommendation attribute comes into play.

You can find the item 'Recommended Attributes' on the document editing page. Anqi CMS provides various preset recommended attributes, each corresponding to a specific letter identifier for easy use in the front-end template:

  • Headline [h][en] Typically used to display the most important and most concerned content, such as the headline news on the home page of a website.
  • Recommend [c][en] Widely used in recommended content areas, such as "Editor's Picks
  • Slideshow [f]【en】:Content suitable for carousel or slideshow display, with strong visual appeal.
  • [en] Recommended [a]: Indicates special recommendation, which may be between the importance of headlines and ordinary recommendations.
  • [en] Scroll [s]【en】:Suitable for news ticker or bulletin board, quickly displaying multiple brief messages.
  • [en] Image [p]The colon indicates a document with high-quality images, suitable for use in a photo gallery or image recommendation spot.
  • [en] Jump [j]If the document link needs to jump to an external page or another specified page within the site, this attribute can be marked.

You can select one or more recommended properties for a document based on the importance of the content or display requirements.For an article that is both a headline and has beautiful images, both 'Headline[h]' and 'Image[p]' can be selected simultaneously.This flexible setting lays a solid foundation for the refined operation of content.

Front-end template call and display: make selected content 'shining'

After completing the background recommendation attribute settings, the next step is to call and display the content with specific attributes on the front page of the website through template tags. The template system of Anqi CMS providesarchiveListLabel, it is the core to achieve this goal.

archiveListLabels allow you to filter and retrieve document lists based on various conditions, including the "flagParameters, specifically used to call documents with specific recommendation attributes.

Here are several common call scenarios and code examples:

  1. Displaying "Top Stories" on the homepage:Assuming you want to display the top 5 most important 'headlines' articles at the top area of the website homepage, and these articles all belong to the 'article' content model (moduleId="1").

    {# 在首页展示头条文章 #}
    <div class="homepage-headlines">
        <h2>今日头条</h2>
        <ul>
            {% archiveList headlines with moduleId="1" flag="h" limit="5" %}
                {% for item in headlines %}
                    <li>
                        <a href="{{ item.Link }}" title="{{ item.Title }}">
                            <h3>{{ item.Title }}</h3>
                            {# 如果头条文章有缩略图,也可以在这里显示 #}
                            {% if item.Thumb %}<img src="{{ item.Thumb }}" alt="{{ item.Title }}">{% endif %}
                        </a>
                    </li>
                {% empty %}
                    <li>暂无头条文章。</li>
                {% endarchiveList %}
            </ul>
        </div>
    

    In the above code,flag="h"Exactly filter out the content marked as 'Headline',limit="5"then controls the display quantity.

  2. Display the 'Recommended' content under a certain category on the special page:If you want to display specific categories (such as 'Product Cases' category) of a certain topic page (for example), and include images for the 'Recommended' products under it.categoryId="10")

    {# 在某个专题页展示特定分类下的推荐产品 #}
    <div class="special-page-featured">
        <h3>精选案例推荐</h3>
        <div class="product-grid">
            {% archiveList featuredProducts with moduleId="2" categoryId="10" flag="c" limit="8" %}
                {% for item in featuredProducts %}
                    <div class="product-item">
                        <a href="{{ item.Link }}" title="{{ item.Title }}">
                            {% if item.Thumb %}<img src="{{ item.Thumb }}" alt="{{ item.Title }}">{% endif %}
                            <h4>{{ item.Title }}</h4>
                            <p>{{ item.Description|truncatechars:50 }}</p> {# 截取50个字符作为简介 #}
                        </a>
                    </div>
                {% empty %}
                    <p>暂无精选案例推荐。</p>
                {% endarchiveList %}
            </div>
        </div>
    

    In this example, we combinemoduleId(product model),categoryId(specified category) andflag="c"(recommendation), precisely filtering out the target content.item.Thumbanditem.DescriptionThese variables are used to display the thumbnail and summary of the content.

archiveListFlexibility of tags:

Exceptflag/moduleId/categoryIdandlimitIn addition to these common parameters,archiveListIt also supportsorder(Sorting method, such as by publication time)id descor viewsviews desc),excludeFlag[Exclude specific attribute content] and other parameters, allowing you to control the display logic of content more finely.By reasonably utilizing these parameters, you can flexibly construct various content display modules according to the actual needs of the website.

Actual application scenarios and effects

Using recommendation attributes to organize content can bring various operational advantages:

  • Enhance user experience:Visitors can quickly find the most important, popular, or relevant information on the website, reducing the time spent on information filtering.
  • Enhance content exposure:Place the core content on the homepage slideshow, headline recommendations, and other prominent positions, which greatly increases the chances of it being clicked and read.
  • Optimize content distribution:Set different recommendation logic for different pages (such as the homepage, category page, and special topic page) to achieve precise content distribution and meet the diverse needs of visitors.
  • Supports marketing activities:With the launch of new products and promotional activities, mark related content as recommended and promote it quickly.

The recommended attribute feature of Anqi CMS is easy to operate, seamlessly integrated with template tags, and is a powerful tool for you to carry out content precision operation and enhance the value of the website.


Common Questions (FAQ)

  1. Question: Can a document have multiple recommended attributes set at the same time? Answer:Yes, a document can select multiple recommended properties at the same time according to actual needs.For example, a popular headline news can check both 'Headline[h]' and 'Recommended[c]'.

  2. Question: How can I display the content of both 'Recommended' and 'Slideshow' attributes in the same area? Answer:You can use two separatelyarchiveListtags to call. For example, use onearchiveListInvokeflag="c"first, then use anotherarchiveListInvokeflag="f"The content. According to the template design, you can place them in adjacent areas, or integrate them for display using some front-end technologies (such as JS carousel).

  3. **Question: Does the order of recommended properties affect the front-end content?