How to implement the 'Recommended Attribute' feature of AnQiCMS for displaying article categories on the front end (such as headlines, recommendations)?

Calendar 👁️ 76

AnQiCMS provides a rich and flexible set of tools for organizing and displaying website content, among which the 'recommended attribute' feature is a very practical design.It allows us to add special tags to articles for classification display on the website frontend, such as highlighting "headlines" articles or displaying "recommended" content in specific areas.

Understanding 'Recommended Attribute'

AnQiCMS's 'Recommended Attribute' is essentially a metadata tag for articles, used to describe the characteristics or importance of the article.In the background content management interface, when you edit or publish an article, you can find the "Recommended Properties" setting item on the article detail page.Here are various predefined properties, each with a concise code:

  • Headline [h]: This is usually used for the most important and most concerned articles on the website.
  • Recommend [c]: Refers to high-quality content edited or recommended by the system.
  • Slide [f]: Articles suitable for appearing in the home page carousel or other image display areas.
  • Special recommendation [a]: Content with special recommendation value.
  • Scroll [s]: Suitable for displaying articles in scrolling news feeds or bulletin boards.
  • Bold [h]: Emphasize the article title to make it more prominent (note that the code is the same as "top story", usually distinguished by style).
  • Image [p]: Indicates that the article contains important images, suitable for image lists or galleries.
  • Jump [j]: Usually used for external links or jump articles that require special handling.

You can select one or more recommended attributes for an article.By checking these properties, you can tag the article, making it convenient for precise calling and display in the frontend template.

Implementation principle in front-end templates.

To display articles on the front end of the website based on these recommended properties, the core lies in using the AnQiCMS providedarchiveListTemplate tag. This tag is used by AnQiCMS to obtain article lists, and it can meet various article filtering needs through flexible parameter settings.

Among them,flagThe parameter is specifically used to filter articles with specific 'recommended attributes.' When you need to display a certain type of recommended article, just specify the correspondingarchiveListtag.flagcode.

For example, if you want to display all articles marked as "top news" in a region, you will write it in thearchiveListtag like this:flag="h".

It should be noted that in a singlearchiveListThe tag call can only specify oneflagFilter by property. If your website needs to display different recommended article lists at the same time (for example, one area displays "Headline" and another area displays "Recommended"), then you need to use differentarchiveListtags to obtain.

OncearchiveListThe tag retrieves the list of articles, we usually useforLoop through the tag to traverse each article's data, and display its title, link, introduction, thumbnail, and other information one by one on the web page.

Practice: Displaying articles in categories on a webpage

Let's look at some specific examples to see how to implement the classification display of articles in the AnQiCMS template.

Assuming we want to display the 'Headline Articles' list and the 'Recommended Articles' list in different areas of the website homepage.

1. Display the 'Headline Articles' list

We may want to display the latest 5 "top" articles at the top of the page or in a prominent position.

In your template file (for exampleindex.htmlorpartial/main_content.htmlIn the brackets, you can write the code like this:

<section class="headline-articles">
    <h2>头条文章</h2>
    <ul>
        {% archiveList headArticles with type="list" flag="h" limit="5" %}
            {% for item in headArticles %}
            <li>
                <a href="{{item.Link}}">
                    {% if item.Thumb %}
                        <img src="{{item.Thumb}}" alt="{{item.Title}}">
                    {% endif %}
                    <h3>{{item.Title}}</h3>
                    <p>{{item.Description|truncatechars:80}}</p>
                </a>
                <span>发布于:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
            </li>
            {% empty %}
            <li>暂无头条文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</section>

This code passesflag="h"The parameter explicitly tellsarchiveListTags only retrieve articles marked as 'Top News'.limit="5"Then it limits the display quantity to 5 articles in.forinside the loop,item.Linkget the article link,item.TitleGet the article title,item.ThumbRetrieve thumbnails,item.DescriptionRetrieve article summaries,stampToDateTags will format the timestamp into a readable date format.

2. Display the 'Recommended Articles' list

Next, we might want to display 10 'recommended' articles in another area.

`twig

Related articles

How to format the article publish time in the template to display it in the specific format of 'Year-Month-Day'?

In website operations, a clear and unified time display format is crucial for improving user experience and content professionalism.Especially the publication time of the article, a standardized "year-month-date" format can make it clear to visitors.In AnQiCMS (AnQi CMS), achieving this is actually very simple and flexible.### Understanding AnQiCMS time handling method When using AnQiCMS, you will find that articles (`archive`) and products and other content all have two key time fields

2025-11-09

How to avoid malicious collection of content in AnQiCMS and add watermarks to images to protect copyright?

In today's world where digital content is increasingly rich and spreads rapidly, protecting the copyright of original content is particularly important.Malicious collection and unauthorized use of images not only harms the creators' labor results, but may also have a negative impact on the website's SEO and brand image.AnQiCMS (AnQiCMS) understands these challenges and therefore incorporates multiple features to help users effectively avoid malicious content scraping and add watermarks to images to protect copyright.In the era of information explosion on the Internet, original content is a valuable asset of the website. However

2025-11-09

How to display the copyright information, filing number, and other global settings on the front-end page?

The footer usually carries important content such as copyright information and filing number, which not only relates to the professional image of the website, but also the legal requirements and the foundation of user trust.In AnQiCMS, these global settings can be configured and called very conveniently, making your website information clear at a glance.Next, we will learn in detail how to configure and display these key information in AnQiCMS.### Step 1: Configure Global Information in the Background First, you need to log in to your AnQiCMS admin panel, find the Back-end Settings in the left navigation bar.

2025-11-09

Can AnQiCMS set independent display templates for different articles? How to operate?

## AnQiCMS: Create a dedicated display template for every article of yours In our daily website operations, the diversity of content presentation is the key to improving user experience, enhancing brand image, and optimizing SEO effects.Different types of articles often require different layouts and features, such as a deep technical analysis article that may require a more focused reading interface, while a product introduction page may require richer image displays and purchase buttons.So, can AnQiCMS (AnQiCMS) meet the need for setting independent display templates for different articles?I can clearly tell you

2025-11-09

How to customize the shutdown prompt displayed to users when the website is closed?

During the operation of the website, we sometimes encounter situations where we need to temporarily close the website, such as system upgrades, server migrations, major content adjustments, or simply brief technical maintenance.How can you clearly and friendliness convey the current status of the website to the visitors at this time and provide necessary information, which is particularly important.AnQiCMS provides comprehensive shutdown management functions for website administrators, allowing us to easily set the shutdown status of the website and highly customize the display of shutdown prompt information.### Enable website shutdown feature When your website needs to be temporarily offline

2025-11-09

How does AnQiCMS manage and display single-page content, such as 'About Us' or 'Contact Information'?

In website operations, single-page content such as "About Us", "Contact Information", "Service Introduction", and "Privacy Policy" is a core element in building the basic information of the website, enhancing user trust, and facilitating users in quickly obtaining information.These pages usually have fixed content, but their importance is self-evident.AnQiCMS provides an intuitive and powerful single-page management mechanism that allows you to easily create, manage, and display these key contents.### Create and Edit Single Page Content: Starting from the Backend Manage Single Page Content in Anqi CMS

2025-11-09

How to generate a clickable table of contents (TOC) based on the title structure of the article content?

In AnQiCMS (AnQiCMS), generating a clickable table of contents (Table of Contents, TOC) for your article detail page is a very practical feature.It can not only significantly improve the reading experience of users, help readers quickly locate the chapters of interest, which is particularly important for long content, but also optimize the page SEO performance to a certain extent.The Anqi CMS provides very practical mechanisms to help us achieve this, the core lies in the clever use of the title structure of the article content.###

2025-11-09

Does AnQiCMS support displaying a list of友情链接 links on the front end and distinguishing whether to add the nofollow attribute?

In website operation, friendship links are not only an important means to expand external resources and enhance website authority, but also the impact on search engine optimization (SEO) needs to be carefully managed.Many website managers are very concerned about whether the content management system they use can flexibly support the display of friendly links and provide control over the `nofollow` attribute to better balance SEO strategies and link collaboration needs.When building a website with AnQiCMS, you will be surprised to find out

2025-11-09