How to filter and display specific content lists based on categories, modules, or recommended attributes?

Calendar 👁️ 79

When using Anq CMS to manage website content, we often need to display specific content (such as articles, products) in the form of a list in different areas of the website.This means that we may need to display the latest headline articles on the homepage, only show products from a specific series on the product category page, or recommend some popular content in the sidebar.AnQi CMS provides flexible tags, allowing us to accurately filter and display the desired content list based on various conditions such as categories, content models, or recommended attributes.

Next, let's explore how to use the powerful template tags of Anqi CMS to achieve these refined content filtering and display.

Understand the Core:archiveListTag

The core tool used to retrieve content lists in AnQi CMS isarchiveListLabel. It is like a universal content filter, which can meet the vast majority of content display needs through the combination of different parameters.

The basic structure of this label is usually like this:

{% archiveList articles with type="list" limit="5" %}
    {% for article in articles %}
        {# 在这里展示每一篇文章的详细信息,比如标题、链接、缩略图等 #}
        <div class="article-item">
            <a href="{{ article.Link }}">{{ article.Title }}</a>
            {% if article.Thumb %}
                <img src="{{ article.Thumb }}" alt="{{ article.Title }}">
            {% endif %}
            <p>{{ article.Description }}</p>
        </div>
    {% endfor %}
{% endarchiveList %}

In the above example,articlesThis is the variable name defined for the list of content obtained, you can name it according to your own habits.type="list"It means we want to get a simple list, andlimit="5"It limits the display to only the latest 5 items.

Filter content by category

The classification of website content is the most basic way to organize information. Anqi CMS allows us to classify articles, products, and other content into different categories.We need to usecategoryIdParameter.

Assuming you have a category named "Company News" with ID10. You can view the corresponding ID for each category on the "Content Management" -> "Document Category" page.

To display all articles under the "Company News" category, you can write the code like this:

{# 显示分类ID为10(例如“公司新闻”)下的内容 #}
{% archiveList newsList with categoryId="10" type="list" limit="8" %}
    <h3>最新公司新闻</h3>
    {% for news in newsList %}
        <div class="news-item">
            <a href="{{ news.Link }}">{{ news.Title }}</a>
            <span>发布日期: {{ stampToDate(news.CreatedTime, "2006-01-02") }}</span>
        </div>
    {% else %}
        <p>暂时没有公司新闻。</p>
    {% endfor %}
{% endarchiveList %}

If your category has subcategories and you want to display the content of all subcategories by defaultarchiveListThe label will include. If you only want to display the content of the current category without including subcategories, you can addchild=falseParameter.

Filter content based on the content model

A key feature of AnQi CMS is its flexible content model function, you can create 'article models', 'product models', even 'event models' to meet different business needs. Each content model has a uniquemoduleId. On the "Content Management" -> "Content Model" page in the background, you can view the IDs of these models.

If you want to display the latest product list on a page, such as the homepage, instead of the article list, you can usemoduleIdto filter. Assuming the ID of the2.

{# 显示产品模型(moduleId="2")下的最新产品 #}
{% archiveList productList with moduleId="2" order="id desc" type="list" limit="6" %}
    <h2>热门产品推荐</h2>
    <div class="product-grid">
        {% for product in productList %}
            <div class="product-card">
                <a href="{{ product.Link }}">
                    <img src="{{ product.Thumb }}" alt="{{ product.Title }}">
                    <h4>{{ product.Title }}</h4>
                </a>
            </div>
        {% endfor %}
    </div>
{% endarchiveList %}

Here we also usedorder="id desc"Make sure to sort products by the latest release.

Filter content based on recommended attributes (Flag)

The Anqi CMS allows you to set various recommended properties for each document, such as "headline", "recommended", "slide" etc. These properties can be easily selected in the document editing interface in the background, and each property has a corresponding single-letter identifier (such ashrepresenting the headline,cRepresents recommendation,fRepresents slide).Pass through,flagParameter,you can create various special display areas on the website.

For example, to display the article marked as "slide (f)" in the carousel position on the homepage:

{# 显示被标记为“幻灯(f)”的内容作为轮播图 #}
{% archiveList sliderItems with flag="f" type="list" limit="5" %}
    <div class="main-slider">
        {% for item in sliderItems %}
            <div class="slider-item">
                <a href="{{ item.Link }}">
                    <img src="{{ item.Logo }}" alt="{{ item.Title }}">
                    <h3>{{ item.Title }}</h3>
                </a>
            </div>
        {% endfor %}
    </div>
{% endarchiveList %}

You can also combine multipleflagValues, separated by commas, for exampleflag="h,c"Content marked as both 'Headline' and 'Recommended' will be displayed at the same time.

Combine multiple filtering conditions.

The strength of AnQi CMS lies in the flexibility to combine the above filtering conditions to achieve more precise content location. For example, you may want to filter in the "Technical Articles" category (categoryId="12") under, filter out the ones belonging to the "article model" (moduleId="1") and marked as "recommended (c)" popular technical articles.

{# 组合筛选:显示技术文章分类下,文章模型中,被推荐的内容,并按浏览量倒序排列 #}
{% archiveList featuredTechArticles with categoryId="12" moduleId="1" flag="c" order="views desc" type="list" limit="4" %}
    <h2>精选技术推荐</h2>
    <ul class="featured-list">
        {% for article in featuredTechArticles %}
            <li>
                <a href="{{ article.Link }}">{{ article.Title }}</a>
                <span>({{ article.Views }} 阅读)</span>
            </li>
        {% endfor %}
    </ul>
{% endarchiveList %}

In this example, we not only combined categories, models, and recommendation attributes, but also throughorder="views desc"Made the most popular articles appear first, and usedlimit="4"Controlled the number of displayed items.

Advanced filtering: Exclude specific content and custom fields

In addition to basic filtering,archiveListit also provides some advanced options, such asexcludeCategoryIdandexcludeFlag, which can exclude specific categories or recommended attribute content.

When you define custom fields (such as "article source") in your website's content model and want to use them for more dynamic filtering, you can consider usingarchiveFiltersThe label, it will generate a filter link based on the custom fields set in your background,配合archiveListofqParameters or URL query parameters are used to filter content. This is usually used to build more complex filtering pages, such as real estate websites filtering listings based on apartment type, area, and other factors.However, the specific implementation involves passing and processing URL parameters, and is more suitable for users with template development experience

Related articles

How to dynamically retrieve and display an article list through template tags in Anqi CMS?

Dynamic display of website content is one of the core elements of modern website operations, which not only enhances user experience and allows visitors to easily find the information they are interested in, but also effectively assists in search engine optimization (SEO), making the website more favored by search engines.In Anqi CMS, through the powerful template tag function, we can very flexibly obtain and display various types of article lists.The AnQi CMS template system has adopted the syntax of the Django template engine, with a natural and smooth style, making it very quick for you who are familiar with frontend development.

2025-11-08

How to configure Anqi CMS to support responsive design or independent mobile content display?

In the era of co-existing multiple devices, websites that can adapt well to various screen sizes, whether PC, tablet, or mobile phone, have become a basic requirement.AnQiCMS (AnQiCMS) understands this and provides a variety of flexible configuration options to help you easily implement responsive design or independent mobile content display, ensuring that your content brings users a high-quality browsing experience on any device.The Anqi CMS provides three main website modes to support multi-terminal display: adaptive, code adaptation, and PC+mobile independent sites

2025-11-08

How to implement independent templates for different pages (such as articles, products, single pages) in Anqi CMS?

In website operation, we often need to adopt completely different layouts and design styles for different types of content, such as a deep article, a product display page, or an 'About Us' single page.This differentiated display not only enhances user experience, but also helps content better convey information and achieve marketing goals.AnQiCMS (AnQi CMS) provides a very flexible and powerful solution in this regard, allowing us to easily implement independent templates for different pages.

2025-11-08

How to customize the display layout of content on the frontend page in Anqi CMS?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides us with great freedom with its powerful template functions and content model, allowing us to finely control the layout of content on the front-end page according to the actual needs of the website.To achieve this goal, we need to deeply understand the template engine, content model, and built-in tags of Anqicms.

2025-11-08

How to implement the complete information display of the content detail page in AnQi CMS (including custom fields)?

In website operation, the content detail page is the core entry for visitors to understand products or services, and the completeness of information display and user experience is crucial.AnQiCMS (AnQiCMS) takes full consideration of the flexibility and customization of content display in its design, even for various custom fields you define, they can also be presented elegantly on the content detail page.Next, we will explore how to fully display all the information of the content detail page in Anqi CMS, from the establishment of the content model to the call of the template, including those unique custom fields.### Build Content Skeleton

2025-11-08

How to optimize image display in content lists and detail pages (thumbnails, multiple images, lazy loading)?

In the digital age where content is king, images on websites are not only visual decorations but also key elements in attracting users, conveying information, and enhancing brand image.However, unoptimized images may also become the culprit that slows down website loading speed, affects user experience, and even damages SEO performance.Fortunately, AnQiCMS (AnQiCMS) provides us with a comprehensive and powerful image optimization tool, allowing the website to maintain visual appeal while achieving high-performance loading.

2025-11-08

How to dynamically display the website navigation menu in Anqi CMS, including secondary or multi-level dropdown menus?

In website operation, a clear and intuitive navigation menu is the foundation of user experience.A well-designed navigation system not only helps visitors quickly find the information they need but also effectively guides them through the browsing path within the website, which has a significant impact on the website's usability and SEO performance.Anqi CMS understands its importance and provides a flexible and powerful navigation management function, allowing you to easily implement dynamic, multi-level navigation menus without writing complex code.

2025-11-08

How to create and display breadcrumb navigation to enhance user experience and page structure visibility?

In website operation, clear navigation is the key to improving user experience.When a visitor delves into the internal pages of a website, a well-designed and easy-to-understand breadcrumb navigation can effectively help them understand their current location and provide a quick way to return to the upper-level page.This not only makes the website structure clear, but also helps search engines better understand the website hierarchy, indirectly optimizing SEO.AnQiCMS (AnQiCMS) fully understands the importance of navigation and has built-in very practical breadcrumb navigation features

2025-11-08