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 "recommended attribute" (Flag).This feature allows you to easily display carefully selected content on the homepage, special pages, or other key locations, thereby guiding visitors' attention and enhancing the interactivity and information delivery efficiency of the website.

Background setting of recommended attributes: the first step of content selection

In the AnQi CMS backend, the starting point for managing content is to publish or edit documents.When you are ready with high-quality content, and hope it can stand out in the key position of the website, the recommendation attribute comes into play.

You can find the "recommended properties" item on the document editing page. Anqi CMS provides a variety of preset recommended properties, each corresponding to a specific letter identifier for easy use in front-end templates:

  • Headline [h]This is usually used to display the most important and most concerned content, such as the headline news on the homepage of a website.
  • Recommend [c]This is widely used in recommended content areas, such as "Editor's Recommendation", "Featured Articles", and so on.
  • Slide [f]: Suitable for use in carousel or slideshow presentations, with strong visual appeal.
  • Special recommendation [a]: Indicates a special recommendation, with importance between headlines and ordinary recommendations.
  • Scroll [s]This is suitable for news scrollbars or bulletin boards, displaying multiple brief messages quickly.
  • Image [p]This indicates a document with high-quality images, which can be used for image galleries or recommended image positions.
  • 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 attributes for a document based on the importance of the content or display requirements.For example, an article that is both a headline and has beautiful pictures can check both This flexible setting lays a solid foundation for the refined operation of content.

Front-end template calling and display: Let the selected content 'shine'.

After setting up the recommended attributes in the background, the next step is to display the content with specific attributes on the front page of the website through template tags. The Anqi CMS template system providesarchiveListThe tag is the core to achieve this goal.

archiveListThe tag allows you to filter and retrieve document lists based on various conditions, including the wordflagThe parameter is used specifically to call documents with specific recommendation attributes.

Here are several common calling 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 of the website homepage, and that 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"Filter out the content marked as 'Top News' precisely,limit="5"which controls the number of displayed items.

  2. Display the 'Recommended' content under a specific category on the special page:If you want to display specific categories (such as the "Product Case" category) of a certain topic page (for example) and recommend products under it, and include images.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.DescriptionVariables are used to display the thumbnail and brief introduction of the content.

archiveListThe flexibility 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) parameters, allowing you to more finely control the display logic of the content.By reasonably using these parameters, you can flexibly build various content display modules according to the actual needs of the website.

The practical application and effect

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

  • Improve user experience:Visitors can quickly find the most important, most popular, or most relevant information on the website, reducing the time spent on information filtering.
  • Enhance content exposure:Place the core content in prominent positions such as the home slide, headline recommendations, etc., which greatly increases the chance of being clicked and read.
  • Optimize content distribution:For different pages (such as the home page, category page, special page) set different recommendation logic to achieve precise content distribution and meet the diverse needs of visitors.
  • Supports marketing activities:Cooperate with the launch of new products, promotional activities, etc., mark relevant content as recommended, and quickly promote it.

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


Frequently Asked Questions (FAQ)

  1. Ask: Can a document set multiple recommended attributes 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 be checked both as 'Headline[h]' and 'Recommended[c]'.

  2. Ask: How do 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 one firstarchiveListInvokeflag="c"and then the otherarchiveListInvokeflag="f"The content. According to the template design, you can place them in adjacent areas, or integrate them through some front-end technologies (such as JS carousel) to display them.

  3. **Ask: The order of recommended properties affects the front-end content.