How can you implement a multi-dimensional filtering function on the article list or product list page (such as by price, attributes)?

Calendar 👁️ 85

I am glad to discuss with you how Anqi CMS can help us achieve multi-dimensional content filtering.In the era of information explosion, users are increasingly pursuing efficiency and personalization in obtaining content.A website that allows users to quickly locate content according to their own needs will undoubtedly greatly enhance user experience and conversion rates.

The AnQi CMS provides very powerful and flexible functions in this aspect, especially through custom content models and specific template tags, we can easily build multi-dimensional filtering functions on article or product list pages, just like the common "price filtering" and "brand filtering" on e-commerce websites.


Empowerment List Page: A Practical Guide to Implementing Multi-Dimensional Content Filtering in AnQi CMS

Imagine when your website has a large amount of content or products, just organizing them through categories often seems inadequate.Users may need to search for the content they are really interested in based on various conditions such as price range, specific attributes (such as color, size), article type, author, and more.AnQi CMS is well-versed in this field, providing us with elegant solutions that make everything simple and efficient.

I. Understanding the Foundation of Multi-Dimensional Filtering: Custom Content Model

To implement multi-dimensional filtering, you first need to have a "dimension". In AnQi CMS, these "dimensions" are what we go throughFlexible content modelCustom fields of various types. The system provides default models such as 'Article Model' and 'Product Model', but the real power lies in being able to create or modify these models according to business needs and add any number of custom fields.

For example, if you are running an e-commerce website, the product list needs to be filtered by “price”, “color”, “size”, and so on. You can find the “content model” in the “content management” backend, select or create a product model, and then add the following custom fields to it:

  • Price (Numeric Type)
  • Color (Multiple Choice or Dropdown, preset options such as Red, Green, Blue, etc.)
  • Size (Single Selection, preset options such as S, M, L, XL, etc.)

If you are a self-media operator, the article list may need to be filtered by 'author', 'article type (such as in-depth reports, opinions, tutorials)' and so on.Similarly, you can add these custom fields to the article model.

These custom fields are not only used for filling in when content is published, but more importantly, they are the 'data source' for building the front-end filtering function.When filling out documents or products, make sure that the data of these custom fields is complete and standardized, which will lay a solid foundation for subsequent filtering functions.

Second, core function: usearchiveFiltersTag builder filter

After we have defined the content model and custom fields, and published content with these fields, the next step is to display these filtering options on the front-end page. Anqi CMS provides a very practical template tag:archiveFilters.

archiveFiltersThe main function of the tag is to automatically extract the customizable fields that can be filtered according to the specified content model, and generate the corresponding filter link.These links will intelligently include the current filter state, ensuring that the page responds correctly when the user selects different filter conditions.

In your article list or product list template (usually){模型table}/list.htmlin these files, you can use it like thisarchiveFilters:

{# 假设我们正在产品列表页,产品模型ID为2 #}
<div>
    <h4>筛选条件:</h4>
    {% archiveFilters filters with moduleId="2" allText="全部" %}
        {% for item in filters %}
        <div class="filter-group">
            <span>{{ item.Name }}: </span> {# 显示筛选维度名称,如“颜色” #}
            <ul>
                {% for val in item.Items %}
                <li class="{% if val.IsCurrent %}active{% endif %}">
                    <a href="{{ val.Link }}">{{ val.Label }}</a> {# 筛选选项,如“红色” #}
                </li>
                {% endfor %}
            </ul>
        </div>
        {% endfor %}
    {% endarchiveFilters %}
</div>

This code will iterate over all custom fields marked as filterable in your product model.For each field, it lists all possible values (such as "red", "blue"), and generates a URL link with the correct filtering parameters.allText="全部"Parameters will add an "All" option for each filtering dimension, making it convenient for users to clear a specific filtering condition.val.IsCurrentThis boolean value is very useful, it can help you add a class to the currently selected filter conditionactivethus highlighting it visually, enhancing the user experience.

3. Display filter results:archiveListThe use of tags

archiveFiltersTags are responsible for generating filter options and links, so who will display the filtered content after the user clicks on these links? The answer isarchiveList.

archiveListTags are not only used to display regular articles or product lists, but they also have a very smart feature: they can automatically identify the filtering parameters included in the current URL (i.e.,archiveFiltersthose included when generating a linkqueryparameters). This means you do not need to write complex logic to parse the filtering conditions from the URL.archiveListIt will automatically query and display matching content based on these parameters.

Following in the same list template,archiveFiltersAfter the tag, you can use it like this.archiveList:

{# 接着上一步的筛选器,显示筛选后的产品列表 #}
<div class="product-list">
    {% archiveList products with moduleId="2" type="page" limit="12" %}
        {% for item in products %}
        <div class="product-item">
            <a href="{{ item.Link }}">
                <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                <h5>{{ item.Title }}</h5>
                {# 如果产品模型有价格字段,可以这样显示: #}
                <p>价格: {% archiveDetail with name="Price" id=item.Id %} 元</p>
                <p>{{ item.Description|truncatechars:100 }}</p>
            </a>
        </div>
        {% empty %}
        <p>没有找到符合条件的产品。</p>
        {% endfor %}
    {% endarchiveList %}

    {# 如果需要分页,可以再添加分页标签 #}
    {% pagination pages with show="5" %}
        {# 分页链接的渲染,此处省略具体代码,可参考文档中pagination标签的用法 #}
    {% endpagination %}
</div>

Here, moduleId="2"We have again ensured that we are querying the product model data.type="page"The parameter indicates that we want the list to support pagination.limit="12"Controls the number of products displayed per page. When the user clicksarchiveFiltersWhen generating the filter link, the page will reload,archiveListit will automatically display only the products that match the filter parameters in the URL.

IV. Optimize user experience: beautify the filter interface and pagination

A powerful filter needs a friendly and beautiful interface. UtilizearchiveFiltersprovidedval.IsCurrentAttribute, you can easily add CSS styles to the currently selected filter option, such as setting its background color to blue or bold font, making it clear to the user.

At the same time, when there is a large amount of filtered content, the pagination feature becomes particularly important. It is very important for AnQi CMS.paginationTags can be used witharchiveListPerfectly matched, generates pagination links that meet the filtering conditions. In this way, the filtering conditions remain unchanged when the user browses multiple pages after filtering, greatly enhancing the continuity of the user experience.

5. Overview of the actual operation process

To implement multi-dimensional filtering of article or product lists, your workflow can be roughly summarized as:

  1. Define or modify the content modelIn the Anqi CMS backend, under 'Content Management' -> 'Content Model', add custom fields to your article or product model and select the appropriate field type (such as single choice, multiple choice, number, etc.).
  2. Enter content and fill in custom fieldsWhen publishing articles or products, be sure to fill in the values of these custom fields completely.
  3. Modify the front-end list template:
    • Insert at the location where you want to display the filterarchiveFiltersSet the labelmoduleIdParameters to match your content model ID.
    • Insert at the location where you want to display the content listarchiveList

Related articles

What thumbnail processing methods does AnQiCMS support to optimize the effect of images in different display scenarios?

In modern website operations, images are not only an important part of the content, but also a key factor affecting user experience and website performance.A well-managed image system can significantly improve the loading speed, visual appeal, and search engine optimization effect of a website.AnQiCMS understands the importance of image optimization and therefore provides users with a variety of flexible thumbnail processing methods to ensure that images achieve the desired effect in various display scenarios.AnQiCMS provides three core strategies for handling image thumbnails, each suitable for different display needs

2025-11-09

How to display the custom parameters of the product on the product detail page (for example: color, size)?

In website operation, adding custom parameters to the product detail page, such as color, size, etc., is an important link to improve user experience and provide more detailed product information.AnQiCMS (AnQiCMS) can easily meet this requirement with its flexible content model and powerful template system.Next, we will discuss in detail how to display these custom parameters on the product detail page.--- ### Step 1: Define custom fields in the product content model backend One of the core advantages of AnQi CMS is its highly flexible content model

2025-11-09

How to correctly render Markdown-formatted article content as HTML and display mathematical formulas in AnQiCMS?

In AnQi Content Management System (AnQiCMS), we are committed to making content creation and display more flexible and efficient.For users accustomed to writing articles in Markdown format, we provide powerful support, ensuring that Markdown content is correctly rendered into HTML, and can easily handle complex mathematical formulas and flowcharts, bringing vitality to technical documents, tutorial articles, and other content.### Enable Markdown Editor: The First Step of Content Creation Enjoy Markdown Convenience in AnQiCMS

2025-11-09

How to implement conditional judgment in a template, for example, whether to display an image based on whether the article has a thumbnail?

In website content presentation, images play a crucial role.However, not all content has corresponding thumbnails, or for design aesthetics and loading speed considerations, we may need to decide based on the actual situation whether to display images, or even display different placeholders.AnqiCMS provides a flexible and powerful template engine, allowing us to easily implement this conditional image display logic, thereby enhancing the flexibility and user experience of website content.This article will focus on how to decide whether to display an image in the AnqiCMS template based on whether the article has a thumbnail

2025-11-09

How to set up multilingual support in AnQiCMS and provide language switching options on the front-end page?

Today, with the deepening of globalization, multilingual support for websites is no longer an option, but a key factor for enterprises to expand into international markets and enhance user experience.AnQiCMS has fully considered this need, providing users with a flexible and powerful multilingual solution to ensure that your content can reach users all over the world and provide a friendly browsing experience in different cultural contexts.The core strategy of AnQiCMS in implementing multi-language functionality is to treat each language as an independent "site" for management, and to combine it with the translation mechanism at the template level

2025-11-09

How to precisely control the display level and sorting order of the navigation menu in AnQiCMS template?

In website operation, a clear and intuitive navigation menu is like a guidepost for visitors to explore the website.A well-designed navigation not only improves user experience but also helps search engines better understand the website structure.AnQiCMS provides a flexible mechanism to help users accurately configure the hierarchy and sorting of navigation menus in the background and implement these controls in the front-end templates. ### Build Navigation Skeleton: Backend Settings Are Key Navigation menu control in AnQiCMS starts from its backend management interface.This is like the blueprint design center of the navigation menu

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 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