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.