How to filter and display content under specific models or categories on the document list page?

Calendar 👁️ 68

When managing website content, we often need to display specific types or themes of content on different list pages, such as article lists, product display pages, or detailed summaries of custom models.This concerns whether users can efficiently find the information they need and also directly affects the overall layout and user experience of the website.Anqi CMS provides us with powerful tools with its flexible content model and efficient system architecture, allowing us to accurately filter and personalize content display.

The core of content organization: models and categories

In Anqi CMS, the organization of website content cannot do without the 'content model' and 'document classification'.The content model defines the structure and properties of content, such as the 'article' model can have a title, body, and publication time fields, while the 'product' model may include product name, price, and inventory fields.By customizing the content model, we can create various types of content based on business needs.

“Document classification” is like a library shelf, used for classifying content.Each document belongs to a specific category, and this category itself belongs to a content model.Such a hierarchical structure makes content management orderly.

To flexibly display this content on the front-end page, the core tool is the template tag. Specifically,archiveListTags are our powerful assistants for displaying content on list pages.

How to filter content by category

The most common content filtering requirement is to display content according to a specific "document category".For example, you may wish to display all articles under the "News Center" on a particular page.

At this point, we just need toarchiveListtags, throughcategoryIdSpecify the category ID in the parameters. This ID is usually found in the background "Document Category" management.

{% archiveList articles with categoryId="1" limit="10" %}
    {% for item in articles %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
    {% empty %}
        <li>目前该分类下没有内容。</li>
    {% endfor %}
{% endarchiveList %}

Sometimes, there may be subcategories under a category. By default,archiveListThe label will also display all documents under the specified parent category ID. If you only want to display documents under the current category without including the content of its subcategories, you can add an extra one.child=falseparameters:

{% archiveList articles with categoryId="1" child=false limit="10" %}
    {# 仅显示分类ID为1的文档,不包含子分类 #}
{% endarchiveList %}

Based on content model filtering display

The flexible content model feature of Anqi CMS is one of its major highlights, allowing us to define different content structures, such as 'articles', 'products', or custom models. If you want to display only specific model content on the list page, for example, only all 'products' and not 'articles', thenmoduleIdThe parameters come into play.

You can find the corresponding model ID in the "Content Model" management in the background. For example, suppose the ID of the "Article" model is 1, and the ID of the "Product" model is 2.

{% archiveList products with moduleId="2" limit="10" %}
    {% for item in products %}
        <li><a href="{{item.Link}}">产品名称:{{item.Title}}</a></li>
    {% empty %}
        <li>目前没有产品信息。</li>
    {% endfor %}
{% endarchiveList %}

This will only display the content under the product model on your list page, and will not mix in articles.

Combine custom parameters for advanced filtering

For more complex, multi-dimensional content filtering needs, such as a real estate website that needs to filter based on 'property type' (residential, commercial) and 'area size' (small apartment, large apartment), Anqi CMS provides 'document parameter filtering tags'——archiveFilters.

First, you need to make sure that these filterable "custom fields" are added to the model in the "content model" backend.For example, add 'house type' and 'area size' fields to the real estate model and set the corresponding options.

Next, in the template,archiveFiltersthe tag is responsible for generating the user interface for the filter conditions, whilearchiveListthe tag will automatically display the corresponding content based on the filter conditions selected by the user.

UsearchiveFiltersat the same time, it also needs to go throughmoduleIdThe parameter specifies which content model's filtering conditions. This tag generates a data structure containing all the filtering conditions, which you can traverse in the template to create click-through filtering links for users.

When the user clicks on these filter links, the link will pass the filter parameters as query parameters in the URL. Amazingly,archiveListLabels will automatically identify and apply these URL filtering parameters, without any additional configuration, and automatically display content that meets the filtering criteria.

A typical usage might look like this:

`twig

<h3>筛选房产:</h3>
{% archiveFilters filterOptions with moduleId="1" allText="不限" %}
    {% for filterGroup in filterOptions %}
        <p>{{ filterGroup.Name }}:</p>
        <div>
            {% for option in filterGroup.Items %}
                <a class="{% if option.IsCurrent %}active{% endif %}" href="{{ option.Link }}">{{ option.Label }}</a>
            {% endfor %}
        </div>
    {% endfor %}

Related articles

How to customize the website navigation menu to display multi-level content links?

During the process of building and operating a website, the navigation menu plays a crucial role.It is not only a guide for users to explore the content of the website, but also the key for search engines to understand the structure of the website.AnQiCMS (AnQiCMS) fully understands this point, therefore it provides a flexible and powerful navigation menu customization feature, allowing us to easily implement the display of multi-level content links, thereby optimizing user experience and enhancing the overall efficiency of the website.Next, we will together learn how to customize and manage the website navigation menu in Anqi CMS, and make it able to flexibly display multi-level content links.##

2025-11-08

How to set independent TDK (title, description, keywords) for the homepage of a website to optimize search results display?

How to make your website stand out among a vast amount of information and gain more exposure in website operation?In this case, Search Engine Optimization (SEO) plays a vital role, and the title (Title), description (Description), and keywords (Keywords), which we commonly refer to as TDK, are the cornerstone of SEO strategy.For users of AnQiCMS, setting up independent homepage TDK is not only simple and efficient, but also a key step in optimizing website search performance.Why is the TDK setting on the homepage crucial

2025-11-08

How to dynamically display contact information in website templates?

When operating a website, we often need to display the company's contact information, such as phone, email, address, and even social media links.The traditional way might be to hardcode this information directly in the template, but this means that every time the contact information changes, you need to modify the code, which is麻烦 and easy to make mistakes.AnQiCMS (AnQiCMS) provides a flexible and efficient solution that allows you to easily display and manage these contact methods in website templates.This means that once the contact information changes, you only need to update it once in the background

2025-11-08

How to flexibly call the system global configuration information for display in the website template?

Flexibly calling the system global configuration information in the website template is a key step in building a dynamic and easy-to-maintain website.AnQiCMS (AnQiCMS) fully understands this need and therefore provided powerful and intuitive template tags from the outset, allowing users to easily display preset system-level data, contact information, and even customized information at any position on the page.The Anqi CMS template system adopts a syntax similar to the Django template engine, where variables are usually defined using double curly braces `{{ variable_name }}`, and various operations and tags are through single curly braces and percent signs

2025-11-08

How to display custom model field information in the document list?

In Anqi CMS, the flexibility of the content model is one of its outstanding advantages.Many times, we not only need to display rich content on the document detail page, but also hope to see key custom information at a glance on the document list page, such as product models, article authors, property prices, vehicle mileage, and so on.This information is often an important basis for users to quickly screen and understand the content.This article will detail how to cleverly display these custom model field information in the document list of Anqi CMS.

2025-11-08

How to manage and display single-page content on the website, such as 'About Us'?

Manage and display single-page content in Anqi CMS: from creation to optimization Most websites cannot do without static pages such as "About Us", "Contact Information", and "Privacy Policy".These pages, although relatively fixed in content, are important windows for users to understand the website and establish trust, and are also key factors for search engines to evaluate the professionalism of the website.AnQi CMS understands the importance of these pages and provides a set of intuitive and powerful tools that allow you to easily manage and beautifully display this single-page content.

2025-11-08

How to classify and manage uploaded image resources, and optimize the front-end display?

In the process of using AnQiCMS to manage website content, the management and optimization of image resources is an essential element for improving website user experience and SEO performance.A well-organized image library not only makes daily operations more efficient, but also ensures that website content is presented in **status across different devices and network environments. ### Picture Resource Classification Management: Say goodbye to chaos and have everything in order AnQi CMS provides us with an intuitive picture resource management interface, making a large number of pictures no longer a problem of piles.To start organizing, we just need to go to the back end

2025-11-08

How to integrate Markdown editor into a website and correctly display mathematical formulas and flowcharts?

In today's increasingly rich digital content, websites are no longer just a pile of text and images.For users who need to display technical documents, academic papers, data analysis reports, and even complex business processes, how to efficiently and beautifully present mathematical formulas and flowcharts has become a key factor in enhancing the professionalism and user experience of the content.AnQi CMS is well-versed in this, providing powerful Markdown editor integration capabilities, with simple frontend configuration, allowing your website to easily support the display of these advanced content.

2025-11-08