How to display document recommendation attributes (such as headline, recommendation) on the document list or detail page?

Calendar 👁️ 56

It is crucial to highlight key content on a website in a content management system to attract users and increase page views.AnQiCMS provides a powerful document recommendation feature that allows website operators to flexibly tag and display articles.This article will introduce in detail how to cleverly use these recommended attributes in the document list and detail page of Anqi CMS, making your website content more vivid and guiding.

Understand the recommended attributes of Anqi CMS

AnQi CMS has designed a variety of recommended attributes for each document, which can be selected during the background editing of documents. They include:Headline[h]/Recommended[c]/Slide[f]/Special recommendation[a]/Scroll[s]/Bold[h]/Image[p]/Jump [j]It is worth noting that these properties can be selected individually, in groups, or not selected at all. Each letter represents a specific property, making it convenient for identification and invocation in front-end templates.

These attributes are not just simple tags, they are the carrier of content operation strategy.For example, you can mark important news as 'headline' and display it in the most prominent position on the homepage;Mark suitable image articles as 'Slideshow' to display in the slideshow area;Or mark high-quality in-depth articles as 'Recommended', highlighting them in the sidebar or related recommendation modules.

Display recommended properties in the document list

On the list page of the website, such as category lists, search result pages, or article modules on the homepage, we often need to filter content based on recommended attributes or directly display the recommended attributes next to each article title. This is mainly achieved byarchiveListthe tag.

1. Filter documents with specific recommended properties

If you want to display documents with the "headline" property only in a specific list area, you can useflagParameters. For example, to list the latest 5 top articles in a block:

{% archiveList archives with type="list" limit="5" flag="h" %}
    {% for item in archives %}
        <li>
            <a href="{{item.Link}}">{{item.Title}}</a>
        </li>
    {% empty %}
        <li>暂无头条文章</li>
    {% endfor %}
{% endarchiveList %}

here,flag="h"EnsuredarchivesThe variable will only contain documents marked as 'Top'. You can replace them as needed.hFor other attribute letters, or use commas to separate multiple attributes (such asflag="hc"Filter documents that are both headlines and recommended).

2. Display the recommended attribute tags of documents in the list item.

If you want to display the recommended attributes of each list article directly next to its title (for example, archiveListusingshowFlag=trueParameter.

OnshowFlag=trueAfter, each in the loopitemThe object will contain oneFlagfield. ThisFlagThe field will return a string that contains the letter abbreviations of all selected recommended properties (for example, "hc" indicates that the document is marked as both "Headline" and "Recommended").You can display the corresponding Chinese or icon through conditional judgment.

{% archiveList archives with type="list" limit="10" showFlag=true %}
    {% for item in archives %}
        <li>
            <a href="{{item.Link}}">
                {%- if item.Flag contains "h" %}
                    <span style="color: red; margin-right: 5px;">[头条]</span>
                {%- endif %}
                {%- if item.Flag contains "c" %}
                    <span style="color: green; margin-right: 5px;">[推荐]</span>
                {%- endif %}
                {{item.Title}}
            </a>
        </li>
    {% empty %}
        <li>暂无文章</li>
    {% endfor %}
{% endarchiveList %}

In the above example,item.Flag contains "h"Used to determine whether the current document contains the attribute “Top News”,item.Flag contains "c"Then determine whether it contains the 'Recommended' attribute. You can add styles or icons for different attributes according to your actual needs.

Display the recommended attribute on the document detail page.

When a user clicks to enter the details page of a document, sometimes it is also necessary to display the recommended properties owned by this article below the title or in the sidebar. This can be done byarchiveDetailTag implementation.

archiveDetailThe label is used to obtain the document detail data of the current page. You can directly access it on the document detail pagearchivean object (usually provided by the system) or usearchiveDetailtags to retrieveFlagfield.

<article>
    <h1>{{archive.Title}}</h1>
    <p class="article-meta">
        发布时间:{{stampToDate(archive.CreatedTime, "2006-01-02")}}
        <span> | </span>
        浏览量:{{archive.Views}}
        <span> | </span>
        <!-- 显示推荐属性 -->
        {%- if archive.Flag contains "h" %}
            <span style="color: red; margin-left: 5px;">[头条]</span>
        {%- endif %}
        {%- if archive.Flag contains "c" %}
            <span style="color: green; margin-left: 5px;">[推荐]</span>
        {%- endif %}
        {%- if archive.Flag contains "f" %}
            <span style="color: blue; margin-left: 5px;">[幻灯]</span>
        {%- endif %}
        <!-- 更多属性判断... -->
    </p>
    <div class="article-content">
        {{archive.Content|safe}}
    </div>
</article>

Here, we directly go througharchive.FlagTo determine the properties of the current document. Ifarchivethe object is not available in the current template context, it can also be usedarchiveDetailto explicitly retrieve using the tag, for example:

{% archiveDetail currentDocFlag with name="Flag" %}
<p class="article-meta">
    <!-- ...其他信息... -->
    {%- if currentDocFlag contains "h" %}
        <span style="color: red; margin-left: 5px;">[头条]</span>
    {%- endif %}
    <!-- 更多属性判断... -->
</p>

Flexible application with tips

  • Style customizationTo make the recommended properties more prominent, you can define unique CSS styles for different properties, such as setting a red background for "headline", a green border for "recommended", or adding small icons to it.
  • Combined Query: You can useflagThe parameter withcategoryId(Category ID),order(Sorting Methods) and otherarchiveListUsing parameters together to achieve more accurate content filtering and display. For example, under a certain category, only display the top 5 'recommended' articles sorted by views.
  • Exclude specific attributes: If you wish to display a regular article list but exclude all 'headlines' articles, you can useexcludeFlag="h"Parameter.
  • Multi-attribute logic: A document may be tagged as both 'headline' and 'recommended',item.FlagIt will return a combined string like 'hc'. In the template, usecontainsThe operator can flexibly determine whether it contains a specific attribute.

The recommended attribute feature of AnQi CMS provides rich tagging and display methods for website content.By the above implementation methods in the document list and detail pages, you can easily manage and highlight important content, enhance user experience, and effectively guide website traffic, ultimately helping you achieve better website operation results.


Frequently Asked Questions (FAQ)

Q1: What do the letter marks recommended by Anqi CMS (such as[h]/[c]) represent?

A1: These letters are the quick tags preset in the Anqi CMS background, convenient for you to quickly select when editing documents. They represent:hrepresenting the headline,cRepresents recommendation,frepresenting slides,aRepresents recommended,sRepresents scrolling,pRepresents image,jRepresents a jump. When you edit documents in the background, you can also see the corresponding detailed explanation by hovering over the recommended attribute options.

Q2: I only want to display the 'Headline' and 'Recommendation' property tags on the list page, and do not want to display other properties (such as 'Slideshow', 'Image'), how can I implement it in the template?

A2: Even if the document has multiple recommended attributes, you can optionally display them. In the template, you only need to make conditional judgments for the specific attributes you want to display. For example:

{%- if item.Flag contains "h" %}
    <span class="flag-headline">[头条]</span>
{%- endif %}
{%- if item.Flag contains "c" %}
    <span class="flag-recommend">[推荐]</span>
{%- endif %}

This, onlyitem.FlagWill display the corresponding mark when the string contains 'h' or 'c'. Other attributes without explicit judgment will not be displayed.

Q3: I set upshowFlag=trueWhy,item.FlagIt returns a string of letters (such as "hc") instead of a Chinese description?

A3:item.FlagThe field returns a string that contains the English abbreviations of all selected recommended properties. This is to provide the greatest flexibility

Related articles

How to display a list of articles or products under a specific category in AnQiCMS?

In AnQiCMS, displaying a list of articles or products under a specific category is a common need in website content management.To build subpages under the navigation menu or to showcase selected content from different modules on the homepage, AnQiCMS offers a flexible and powerful way to achieve this goal.Understanding the content organization logic and the use of template tags will allow you to easily present the required content on the website.### Understanding AnQiCMS content model and categories Firstly, the organization of AnQiCMS content is based on "content model" and "categories"

2025-11-07

How to retrieve and display a list of articles or products in a loop?

Build an energetic website in AnQiCMS, the display of the content list is an indispensable part.Whether it is to display the latest released articles, hot products, or content under specific categories, AnQiCMS' powerful template engine can help us easily achieve it.This article will delve into how to retrieve and loop through lists of articles or products in AnQiCMS, helping you flexibly build diverse content display pages.## Understanding AnQiCMS content list mechanism AnQiCMS uses a template engine syntax similar to Django

2025-11-07

How to dynamically generate and display the top or bottom navigation menu of a website?

In website operation, the top and bottom navigation menus play a vital role. They are not only guides for users to explore the website's content but also crucial for search engines to understand the website's structure.A well-designed, dynamically generated navigation menu that can greatly enhance user experience and website maintainability.AnQiCMS provides a set of intuitive and powerful features to help you easily achieve this goal.### Backend Configuration: Bring Your Menu to Life To dynamically generate and display navigation menus in AnQi CMS, you first need to configure the menu content in the backend

2025-11-07

How to generate and display multi-level breadcrumb navigation in AnQi CMS?

In website content operation, a clear navigation path is crucial for user experience and search engine optimization.A good breadcrumb navigation can help users quickly understand the current page's position in the website structure and make it convenient for them to backtrack to the previous level or higher-level pages.AnQiCMS (AnQiCMS) fully understands this, therefore it provides a powerful and easy-to-use breadcrumb navigation feature that allows website administrators to easily generate and display multi-level breadcrumbs.The core of implementing breadcrumb navigation in Anqi CMS lies in its built-in `breadcrumb` tag

2025-11-07

How to display the detailed content of articles or products and support lazy loading of images?

A Guide to Displaying Content Details and Lazy Loading Images in AnQi CMS in Today's Digital World, the way websites present content directly affects user experience and search engine rankings.Whether it is a detailed article introduction or a beautiful product display, how to present the content efficiently and aesthetically to the visitors and ensure the website loading speed is a challenge that every operator needs to face.AnQiCMS (AnQiCMS) is a powerful content management system that provides us with flexible tools to meet these challenges.This article will delve into how to fully utilize the functions of Anqi CMS

2025-11-07

How to get and display the previous/next content of the current document?

In content-based websites, providing visitors with a convenient navigation experience is crucial, among which the 'Previous' and 'Next' functions are standard features of the article detail page.They can not only guide users to continue browsing more content, effectively increase the website's PV (Page View), but also help search engines better understand the structure of the website's content to optimize SEO performance.AnQiCMS fully considered this requirement, providing us with very simple and intuitive template tags to easily implement this feature.### Learn about AnQiCMS template mechanism At

2025-11-07

How to display the list of recommended content related to the current document in AnQi CMS?

When operating a website, we often hope that users can smoothly find more interesting content after reading a wonderful article.This not only extends the user's stay time and reduces the bounce rate, but is also an effective way to enhance the overall value of the website's content and SEO performance.AnQi CMS knows this, and therefore it provides a variety of flexible ways to display the recommended content list related to the current document, helping us better guide users. To implement recommendations for related content, we first need to understand how Anqicms defines 'related'.In system design, "related" can be reflected at several levels

2025-11-07

How to customize the display of thumbnail and cover images for articles or products?

In website content operation, the visual appeal of images is crucial.Whether it is to show the essence of an article or highlight the highlights of a product, a suitable thumbnail and cover image can greatly enhance the user experience and have a positive impact on the spread of content.AnQiCMS (AnQiCMS) offers rich and flexible features, allowing us to easily customize the display of images for articles or products according to specific needs.This article will introduce how to manage and display thumbnails and cover images in AnQi CMS from two aspects: background configuration and template calling.--- ### One

2025-11-07