How does AnQiCMS control the special display style of articles by setting the Flag attribute?

Calendar 👁️ 71

In Anqi CMS, the Flag attribute of the article is a very practical feature that allows us to tag articles with special "labels", thus achieving a unique way of display on the website front-end.This mechanism greatly enhances the flexibility and diversity of content display, allowing website operators to easily control the display style and position of articles according to the importance, characteristics, or promotional needs of the content.

What is the article Flag attribute?

In simple terms, the Flag attribute is like a special "mark" applied to articles, which is not a category of the article, nor is it a common tag (Tag), but is used to indicate how the article should be "recommended" or "highlighted" in specific scenarios.By setting different Flag attributes, we can easily set some articles as the headline of the homepage, slide content, recommended articles, bold display, and even as special jump links, etc.AnQi CMS has preset a variety of Flag attributes for us to directly select.

In Anqi CMS, common Flag attributes and their codes include:

  • Headline[h]: It is usually used to mark the most important and most eye-catching articles on the website homepage.
  • Recommended[c]This refers to recommended reading content, often used in sidebars or related recommendation areas.
  • Slide[f]This is designed for slide or carousel areas, marking articles that can be displayed in the carousel.
  • Featured[a]:A special recommendation content that is further than ordinary recommendations.
  • Scrolling[s]:Applicable to announcements or news that need to be scrolled on the page.
  • Bold[b]:Indicate that the article title or other text should be displayed in bold style to attract user attention.
  • Image[p]:Emphasize that the article contains important image content, which may be used in a picture list.
  • Jump[j]Set the article link to an external jump, click to go directly to the specified URL.

These properties together constitute the foundation of AnQi CMS flexible content display, making the content no longer just a simple list presentation, but becoming vivid according to the operational strategy.

How to set the article Flag attribute in AnQiCMS backend?

The process of setting the Flag attribute of the article is very intuitive. When you edit or publish articles on the Anqi CMS backend, you will notice a section named 'Recommended Attributes'.Here will be listed all available Flag properties, presented in a checkbox form.

You can select one or more corresponding Flag attributes based on the actual needs of the article and the special style you want it to appear in on the front end. For example, if you want a newly published article to appear in both the 'Headline' area and the 'Slider' carousel on the homepage, you can select them at the same time[h](Headline) and[f](Slide) These two properties. It is worth noting that an article can have multiple Flag properties, which provide the possibility of various display methods.After setting up, save the article. These marked articles will carry their unique 'identity tags' and wait to be called in the front-end template.

How to call and display articles with Flag attributes in the front-end template?

Presenting articles with the Flag attribute on the website front end is a crucial step in utilizing the value of the Flag attribute. In the template design of Anqi CMS, we mainly use powerfularchiveListTag to call these special articles.

archiveListTags providedflagParameters, allowing you to precisely specify which Flag attributes of articles you want to retrieve. For example, to retrieve all articles marked as "Top News", you can use the template.flag="h"such parameters.

This is a basic template call example, showing how to get the latest 5 articles marked as 'Headline' and display their titles and links:

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

In the code above,archiveListTag throughflag="h"Parameters filter articles with the attribute "Top News" and pass throughlimit="5"Limit the display quantity to 5 articles.headlinesThe variable will contain the data of these articles, and then you canforloop through and display them.

exceptflagparameter,archiveListTags also supportexcludeFlagThe parameter is used to exclude articles with a specific Flag attribute. For example, if you want to display all recommended articles except for slide articles, you can write it like this:

{% archiveList recommended with flag="c" excludeFlag="f" limit="10" %}
    {% for item in recommended %}
    <div class="recommended-item">
        <h4><a href="{{item.Link}}">{{item.Title}}</a></h4>
        <p>{{item.Description}}</p>
    </div>
    {% endfor %}
{% endarchiveList %}

In addition, if you need to determine whether a single article in the list has a certain Flag attribute,archiveListit also supportsshowFlag=truethe parameter will expose the article's,Flagfield directly. For example:

{% archiveList featuredArticles with showFlag=true limit="10" %}
    {% for item in featuredArticles %}
    <li class="{% if item.Flag contains 'b' %}bold-title{% endif %}">
        <a href="{{item.Link}}">{{item.Title}}</a>
        {% if item.Flag contains 'p' %}<span>[图]</span>{% endif %}
    </li>
    {% endfor %}
{% endarchiveList %}

here, we check throughitem.FlagDoes the field contain a specific Flag code (such as'b'to indicate bold,'p'indicating an image), to determine the application of different CSS styles or display additional information.

For a single article detail page, you can also usearchiveDetailtags to get the Flag attribute of the current article and make front-end display logic judgments based on this. For example,{% archiveDetail with name="Flag" %}Returns the string of all Flag attributes of the current article, you can further use conditional judgments in the template to handle.

Example of practical application scenarios

The application scenarios of the Flag attribute are very extensive, which can help websites achieve more refined content operations:

  1. The headline area of the homepageSet the most important news or announcements to:[h](Headline) attribute, used at the top or in the core area of the homepagearchiveListTag call to get the highest exposure.
  2. Website slideshow/slide show: Used to set promotional articles or product pages for the website's top carousel[f](Slide) attribute and use it in the template of the slide areaarchiveListcooperateflag="f"to call it, to achieve dynamic display.
  3. Sidebar Recommendation Module: Modules such as "Hot Articles", "Recommended Products", and others on the website sidebar can be set for related content.[c](Recommended) or[a](Special Recommendation) attribute, and then through the correspondingarchiveListLabel to fill in.
  4. Visual distinction in the content list: In the normal article list, you can set some articles that you want users to pay special attention to.[b](Bold) property. In the template, combineshowFlag=truewith conditional judgments, add special CSS classes to the titles of these articles, such as.bold-titleto distinguish visually.
  5. External link articles: If an article actually guides users to access external websites, you can set[j](Redirect) attribute, and determine this attribute in the template, directly link the article to the external URL, and may also addtarget="_blank"andrel="nofollow".

By using these flexible Flag attribute settings and template calls, Anqi CMS helps us achieve diverse content display, making the website content more attractive and greatly improving operational efficiency.


Frequently Asked Questions (FAQ)

Can an article set multiple Flag attributes?

Yes, an article can have multiple Flag attributes at the same time. For example, you can set an important article as a "top news" at the same time[h]and "slide"[f]So that it can be displayed simultaneously in the headline area and the slideshow carousel on the homepage.

2. What is the impact if I set the Flag attribute but do not call it in the template?

If you set the Flag attribute for the article but the front-end template does not write the corresponding call logic, then these Flag attributes will have no effect on the display of the article.They merely exist in the background as metadata for articles and do not automatically present any special styles on the frontend.

3. Can I customize the type of Flag attribute or add new Flag codes?

According to the design of AnQi CMS, the built-in Flag attribute is fixed to 8 types ofh,c,f,a,s,b,p,jThese properties are usually sufficient to cover most common display requirements.The AnQi CMS aims to provide a simple and efficient solution, therefore the functionality of custom Flag types is usually not within its core design scope.If you need more complex custom content identifiers, it is recommended to use the custom fields or tags of the article (Tag) to achieve this.

Related articles

How to automatically wrap long text for display in AnQiCMS templates?

During the operation of the AnQiCMS website, we often encounter scenarios where we need to display a large amount of text content, such as the main content of article detail pages, detailed descriptions of product introductions, or long introductions on category pages.These long texts, if not handled properly, may cause page layout to be disordered and affect the user's reading experience.Fortunately, AnQiCMS's powerful template engine provides various flexible ways to manage and display these long texts, including automatic line breaks and content truncation.AnQiCMS's template system has adopted the syntax of Django template engine, allowing us to use double curly braces

2025-11-07

How to automatically filter or process external links in AnQiCMS article content?

In daily website content operation, we often encounter situations where external links need to be cited in articles.These external links are handled well, they can enrich the content and provide references, but if not managed properly, they may also affect the SEO performance or user experience of the website.AnQiCMS is a content management system that focuses on efficiency and SEO, providing practical automated solutions in this aspect, helping us better manage external links in the article content.### Core options in the background content settings The core mechanism of AnQiCMS handling external links in articles

2025-11-07

How to truncate a string and add an ellipsis (...) in AnQiCMS templates?

In website content management, we often need to present a long text (such as an article abstract, product description) in a concise way on the page, which can not only save space but also improve the user's browsing efficiency.If the long text is not processed and displayed directly in the list, it may lead to a disorganized page and affect the user experience.The template engine of AnQiCMS (AnQiCMS) provides flexible and powerful filter (Filters) functionality, which can help us easily implement string truncation and automatically add ellipses.### AnQiCMS

2025-11-07

How to display a message form on the AnQiCMS website and support the display of custom fields?

Today, with the increasing importance of digital operation, the website message board is not only an important bridge for user interaction with the website, but also a key channel for collecting user feedback and understanding market demand.AnQiCMS (AnQiCMS) fully understands this need, providing flexible and powerful form display and custom field support, allowing you to easily create an interactive platform that meets business requirements. ### Step 1: Configure the custom fields of the comment form To give the comment form more personalized information collection capabilities, we need to configure it first in the Anqi CMS backend.

2025-11-07

How to judge if a variable is empty in the template and display a default value?

During the presentation of web content, we often encounter such situations: a variable may be empty due to data loss, user failure to fill in, or other reasons.If you directly output these empty variables in the template, it may result in blank spaces on the page, affecting the appearance, or even cause layout errors, and may even expose unnecessary debugging information.It is particularly important to set a suitable default value for these variables that may be empty to ensure the completeness of website content display and the smoothness of user experience.The AnqiCMS uses a template engine syntax similar to Django

2025-11-07

How to implement custom template file calling for category or article detail pages in AnQiCMS?

During the process of building a website with AnQiCMS, we often encounter such needs: we hope that a certain category list page or a unique article detail page has a layout and style that is different from the global unified default template.AnQiCMS is a content management system focused on flexibility and customization, providing a very convenient and powerful solution in this regard, allowing us to easily implement this fine-grained template calling.Implement custom template calling for category or article detail pages, AnQiCMS mainly provides two main methods

2025-11-07

How to format numbers in AnQiCMS templates, such as retaining decimal places?

In AnQiCMS template development, formatting numbers for display, especially controlling decimal places, is a very common requirement.No matter whether you want to display the price of products, the percentage in statistical data, or other values that need to be presented accurately, AnQiCMS's powerful template engine provides flexible filters (filters) to help you achieve these goals.

2025-11-07

How to automatically add watermarks to images in article content in AnQiCMS to protect copyright?

In today's era of increasingly rich digital content, the copyright protection of original images is particularly important.Whether it is a carefully photographed product image or an illustration drawn for an article, they all embody the creator's efforts and the brand image of the website.However, the situation where pictures are downloaded and used without permission is common, which not only violates copyright but may also dilute brand influence.Luckyly, AnQiCMS provides a convenient and efficient solution that helps us automatically add watermarks to images on the website, thereby effectively protecting original content.

2025-11-07