How to filter and display articles in a list or category list based on recommended attributes (such as "Top Story

Calendar 👁️ 69

How to effectively highlight key information in content management and website operations to guide users to pay attention to specific articles, which is crucial for improving the effectiveness of the website.AnQiCMS (AnQiCMS) offers a flexible recommendation feature that allows you to easily filter and display articles in article lists or category lists based on attributes such as "Headline" and "Recommended", thus better implementing content operation strategies.

Understanding recommendation attributes: the core tool of content operation

In the Anqi CMS backend, when we publish or edit articles, we will see an option called "recommended attribute".These properties are an important way to classify and tag your articles, they can not only help you organize content, but also achieve differentiation on the front-end page.

  • Headline[h]Indicates that the article has the highest priority, usually used in the most prominent position on the homepage.
  • Recommended[c]It indicates that the article is worth recommending to users and can be displayed in various recommendation areas.
  • Slide[f]It is usually used in the carousel or slideshow area.
  • Featured[a]It is a special recommendation and may have higher weight than ordinary recommendations.
  • Scrolling[s]: Suitable for displaying in scrolling news or announcement areas.
  • Bold[h]: Mainly used for visual emphasis, making titles stand out in lists (similar to headlines identifier, but usually focused on style).
  • Image[p]:Emphasize that the article contains important images, suitable for image display lists.
  • Jump[j]:Indicate that the article, when clicked, will jump to an external link or specified page.

By checking these properties, the article is tagged with specific 'tags', laying a foundation for flexible calls on the front-end page.

How to filter and display articles with specific recommended attributes in the article list

To implement the filtering and display of articles, we need to use the powerful template tags of Anqi CMSarchiveList. This tag allows you to get a list of articles based on various conditions (such as model ID, category ID, recommended attributes, etc.)

Suppose you want to display a "Top News" article in a certain area of the website, you can use it like thisarchiveListTags:

{# 筛选并显示所有标记为“头条”的文章 #}
<div class="headline-section">
    <h2>最新头条</h2>
    {% archiveList headlines with type="list" flag="h" limit="5" order="id desc" %}
        {% for item in headlines %}
            <div class="headline-item">
                <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
                <p>{{item.Description}}</p>
                <time>{{stampToDate(item.CreatedTime, "2006-01-02")}}</time>
            </div>
        {% empty %}
            <p>当前暂无头条文章。</p>
        {% endfor %}
    {% endarchiveList %}
</div>

In this example:

  • headlinesis a custom variable name used to store the list of articles obtained.
  • type="list"indicate that we hope to obtain a non-paginated list.
  • flag="h"is a core parameter, it tells the system to only filter out articles marked as 'top news'.
  • limit="5"limits the display to 5 articles.
  • order="id desc"Then, list the articles in reverse order by article ID (i.e., the most recently published).

exceptflagParameters, you can also combine other parameters for more refined filtering, such as specifying articles under a specific model or category:

{# 筛选并显示“文章模型”下,“分类ID为10”的“推荐”文章 #}
<div class="recommended-section">
    <h2>分类推荐</h2>
    {% archiveList recommended_articles with type="list" moduleId="1" categoryId="10" flag="c" limit="4" order="views desc" %}
        {% for item in recommended_articles %}
            <div class="recommended-article-item">
                <img src="{{item.Thumb}}" alt="{{item.Title}}">
                <h4><a href="{{item.Link}}">{{item.Title}}</a></h4>
                <span>阅读量: {{item.Views}}</span>
            </div>
        {% empty %}
            <p>当前分类暂无推荐文章。</p>
        {% endfor %}
    {% endarchiveList %}
</div>

Here we have addedmoduleId="1"And assuming the article model ID is 1categoryId="10"To lock the source of the article and useflag="c"Filter articles with the recommendation attribute, sorted by reading volume in reverseorder="views desc"Display.

Apply filtering in the category list or on a specific template page

This method is not only suitable for the homepage or custom page, but also can be flexibly used in category list pages. When you use a category list page (such as{模型table}/list.htmltemplate) when usingarchiveListtags, if omittedcategoryIdparameter,

Related articles

How to dynamically display different group Banner slideshows on the website homepage?

The banner carousel on the homepage is an important window to attract visitors' attention and convey core information.By cleverly setting up, we can allow the home page banner slideshow to dynamically display according to different marketing goals or content themes, which can not only improve user experience but also effectively guide users to browse.AnQiCMS (AnQiCMS) offers flexible features to help users easily meet this requirement.Understanding the Banner mechanism of AnQi CMS In AnQi CMS, the management and display of banners have a clear logic

2025-11-08

How to implement the switching display of multilingual website content and adapt to users of different languages?

Today, with the deepening of globalization, a website that supports multilingualism has become a basic requirement for enterprises to expand into international markets and serve global users.AnQiCMS deeply insight into this trend, providing users with a highly efficient and flexible multilingual website content management solution, helping your website easily switch between different language content display and better adapt to users around the world.The core concept of AnQiCMS implementing multi-language website content switching is based on multi-site management.

2025-11-08

How to enable Markdown editor rendering content on the front-end page and display mathematical formulas and flowcharts?

Content operation plays a crucial role in the digital age today.The strength of a Content Management System (CMS) largely depends on its ability to flexibly support a variety of content presentation forms.AnQiCMS (AnQiCMS) leverages its efficient and flexible features to provide a vast space for content creators.Today, we will delve into how to elegantly enable Markdown editor to create content on the Anqi CMS front-end page, and further realize the rendering of mathematical formulas and flowcharts, making your website content more expressive.###

2025-11-08

How to display the current page's canonical URL in the template to optimize SEO?

In website operations, Search Engine Optimization (SEO) is one of the core tasks to enhance website visibility.Among them, the setting and correct display of the canonical URL (Canonical URL) is crucial for avoiding content duplication, optimizing crawling efficiency, and concentrating page weight.AnQiCMS (AnQiCMS) is a highly SEO-focused enterprise-level content management system that provides users with convenient tools for managing and deploying standardized links.What is a Canonical URL?

2025-11-08

How to display the article list according to different sorting rules (such as latest, views, custom sorting)?

Managing website content in Anqi CMS, flexibly controlling the display order of article lists is crucial for improving user experience and content distribution efficiency.Whether you want to immediately display the latest released content to visitors, highlight the most popular hot articles, or manually adjust the arrangement of articles according to specific operational strategies, Anqi CMS provides a simple and powerful way to meet these needs.One of the core advantages of AnQi CMS is its intuitive and feature-rich template tag system.

2025-11-08

How to implement content pagination display and customize page navigation style in AnQiCMS template?

As the content of the website becomes richer, how to efficiently display a large amount of information while ensuring a user-friendly browsing experience is an indispensable link in website operation.In AnQiCMS, through the powerful template tag system, we can easily achieve content pagination display and flexibly customize the style of page navigation, making the website content both rich and tidy.--- ### Efficient Content Organization: Implementing Pagination of Content Lists In the AnQiCMS template, the core of implementing content pagination is to use the `archiveList` tag to retrieve document lists

2025-11-08

How to implement a search function on the front end of a website and display a list of search results with highlighted keywords?

When building a rich website, providing an efficient and convenient search function is a key aspect of improving user experience.AnQiCMS (AnQiCMS) has fully considered this from the beginning of its design, through its flexible template engine and built-in tags, we can relatively easily implement search functionality on the website front-end, and further optimize it to make the keywords in the search results stand out and highlight prominently.### Core Mechanism: Understanding the Search Principle of AnQiCMS The core of AnQiCMS website frontend search lies in `search/index.html`

2025-11-08

How to implement filtering in the article list based on custom parameters (such as product features, price range)?

In website operation, we often need to classify and filter content lists more finely to help users quickly find the information they are really interested in.Traditional article classification can solve most problems, but when the content attributes become more complex, such as products with multiple characteristics, price ranges, or events with different themes and participation methods, a single classification seems to be inadequate.

2025-11-08