How to use the `archiveFilters` tag in Anqi CMS to implement multiple condition filtering, such as "house type" and "area"?

Calendar 👁️ 68

In today's information explosion in the network world, users' demand for obtaining information is becoming more and more precise.A great website should not only be rich in content but also provide an efficient and convenient content filtering function to help users quickly locate the information they need.As an experienced website operations expert, I am well aware of the importance of refined filtering for improving user experience and website conversion rates.archiveFiltersIt can help you easily implement multi-condition filtering, for example, on real estate websites, filtering accurately according to "house type" and "area

AnQi CMS, with its flexible content model and powerful template system, provides website operators with a great degree of freedom. The core of implementing multi-condition filtering lies in two points: first, you need to define the custom fields available for filtering through the 'Content Model' function of the AnQi CMS backend; second, utilizingarchiveFiltersTags are dynamically generated on the front end to create these filtering conditions and combine them witharchiveListandpaginationTags to display the filtered content.

Basic construction: Understanding the principle of custom content models and filtering

In Anqi CMS, whether it is articles, products, or any other type of content, it is all built based on the 'content model'.To implement multi-screening for 'house type' and 'area', you first need to add these custom fields to your 'real estate' content model in the background.

  1. Create or edit the content model:

    • Enter the AnQi CMS backend, find 'Content Management' -> 'Content Model'.
    • You can choose to edit an existing 'article model' or 'product model', or create a new 'real estate' content model.
    • Click to enter the model details, in the "Content Model Custom Fields" area, add the following fields:
      • House type:
        • Parameter name:房屋类型
        • Call field:houseType(Suggested to use camelCase naming)
        • Field type:单项选择or下拉选择(For example: apartment, villa, shop, office building)
        • Default value: enter one option per line, for example:
          
          公寓
          别墅
          商铺
          写字楼
          
      • Area:
        • Parameter name:面积
        • Call field:areaRange
        • Field type:下拉选择(It is usually defined as a range option for easy filtering, rather than entering numbers directly)
        • Default value: for example:
          
          50-80平米
          80-120平米
          120-150平米
          150平米以上
          
    • After saving the content model, you can select the corresponding "house type" and "area" when you publish real estate information.
  2. archiveFiltersmechanism:archiveFiltersThe elegance of the tag lies in its ability to intelligently read the filterable fields configured in your content model (such as single-choice, multiple-choice, dropdown selections), and then dynamically generate a series of filter options, and for each option generate a query parameter with a specific query (such as?houseType=公寓or?areaRange=80-120平米The URL link. When the user clicks on these links,archiveListThe tag automatically identifies these parameters in the URL and filters out matching content from the database according to these conditions.This means, you do not need to manually write complex query logic, Anqí CMS has taken care of everything for you.

MasterarchiveFiltersTag: Multi-filter template实战

archiveFiltersTags are mainly used on the front end of a website, such as content list pages or category pages, to generate dynamic filtering interfaces. They usually need to be linked witharchiveListandpaginationUse labels in conjunction to achieve the complete function of generating filter conditions, displaying content lists, and pagination navigation.

Let's take a look atarchiveFiltersbasic usage and the powerful capabilities it provides:

`twig {# Assume your "Real Estate" content model ID is 1, please modify moduleId according to actual conditions #}

<h3>房产筛选</h3>
{% archiveFilters filters with moduleId="1" allText="不限" %}
    {% for item in filters %}
    <div class="filter-group">
        <span class="filter-label">{{item.Name}}:</span>
        <ul class="filter-options">
            {% 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 %}

{# Real estate list display area, ensure type=“page” to support filtering and pagination #}

{% archiveList archives with moduleId="1" type="page" limit="10" %}
    {% for item in archives %}
    <div class="house-item">
        <a href="{{item.Link}}">
            <img src="{{item.Thumb}}" alt="{{item.Title}}">
            <h4>{{item.Title}}</h4>
            <p>{{item.Description}}</p>
            {# 可以在这里显示自定义字段,例如: #}
            <p>类型:{% archiveDetail with name="houseType" id=item.Id %}</p>
            <p>面积:{% archiveDetail with name="areaRange" id=item.Id %}</p>
        </a>
    </div>
    {% empty %}
    <p>抱歉,没有找到符合条件的房产信息。</p>
    {% endfor %}
{% endarchiveList %}

{# 分页代码 #}
<div class="pagination-area">
    {% pagination pages with show="5" %}
        {# 首页 #}
        <a class="page-link {% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
        {# 上一页 #}
        {% if pages.PrevPage %}
        <a class="page-link" href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a>
        {% endif %}
        {# 中间多页 #}
        {% for pageItem in pages.Pages %}
        <a class="page-link {% if pageItem.IsCurrent %}active{% endif %}" href="{{pageItem.Link}}">{{pageItem.Name}}</a>
        {% endfor %}
        {# 下

Related articles

Are the filtering links generated by the `archiveFilters` tag SEO-friendly? What built-in optimizations does AnQi CMS provide for this?

As an experienced website operation expert, I am well aware that in today's highly competitive online environment, the SEO-friendliness of the Content Management System (CMS) is the foundation for the success of the website.AnQiCMS is known for its efficiency and flexibility, and the `archiveFilters` tag it provides is a topic of concern for many operators, as it affects SEO and has built-in optimization strategies in generating filtering links.Today, let's delve deeply into this topic.

2025-11-06

The `archiveFilters` tag generates each filter option (`Items`) and includes which available fields, such as `Label`, `Link`, `IsCurrent`?

As an experienced website operations expert, I deeply understand the importance of content organization and user experience for the success of a website.AnQiCMS (AnQiCMS) with its powerful content management and flexible template customization capabilities has become my powerful assistant in efficiently operating my website.Today, let's delve into the `archiveFilters` tag, especially the key fields included in each filter option (`Items`), which are the foundation for refined content filtering and optimizing user experience.

2025-11-06

What do the `Name` and `FieldName` fields represent in the `filters` variable? How are they used in the template?

As an experienced website operations expert, I have a deep understanding of the importance of efficient and flexible template usage in content management systems (CMS) for website operations efficiency and user experience.AnQiCMS (AnQiCMS) offers us powerful content operation tools with its concise and efficient characteristics, especially its flexible template tag system, making content display as easy as pie.

2025-11-06

What is the structure of the `archiveFilters` tag returned `filters` variable? How to traverse the data within it?

AnQi CMS is an efficient and customizable enterprise-level content management system, playing a vital role in the content operation field.It not only provides powerful content publishing and management capabilities, but also through a series of flexible template tags, gives the website a high degree of customization and interactivity.Today, let's delve into one of the very practical tags - `archiveFilters`, and how it helps users accurately locate content in vast amounts, thereby significantly improving the user experience and content discovery efficiency of the website.

2025-11-06

After the page loads, is the `archiveFilters` tag dynamically generated or statically pre-generated?

AnQiCMS (AnQiCMS) is an enterprise-level content management system with efficiency, security, and SEO-friendliness as its core, fully reflecting these concepts in the design of its template tags.Regarding the question you raised, is the `archiveFilters` tag dynamically generated as a filter condition or statically pre-generated?This topic, we can delve into the unique aspects of AnQiCMS in handling such features.

2025-11-06

If the `archiveFilters` tag does not display any filtering conditions, what are the common troubleshooting steps?

## AnQiCMS `archiveFilters` tag does not display filter conditions?Expert leads you step by step troubleshooting!As website operators, we fully understand the importance of a smooth and efficient user experience for the website.AnQiCMS provides the `archiveFilters` tag, which is to help us build this experience, it can dynamically generate filtering conditions according to the various parameters of the document, greatly enhancing the discoverability of content.

2025-11-06

Does the `archiveFilters` tag support filtering user-defined "content model custom fields"?

As an experienced website operations expert, I am well aware of the importance of the flexibility of a content management system (CMS) in efficient operations, and AnQiCMS, with its powerful content model customization capabilities, has provided us with great convenience in this regard.Today, let's delve deeply into a question that concerns everyone: Does AnQiCMS's `archiveFilters` tag support filtering custom fields of the content model?

2025-11-06

Under multi-site management scenarios, how does the `siteId` parameter of the `archiveFilters` tag ensure that the correct site's data is filtered?

As an experienced website operations expert, I am well aware that efficient and accurate content management is the cornerstone of success in a complex digital environment.AnQiCMS (AnQiCMS) takes advantage of its powerful multi-site management capabilities, providing great convenience for operators.However, with the increase in the number of managed sites, how to ensure that the data filtered in specific scenarios comes from the target site we want, rather than the current site or other irrelevant sites, this involves a crucial parameter in the `archiveFilters` tag - `siteId`.###

2025-11-06