How to build a complex search interface for product filtering or property filtering using the `archiveFilters` tag?

Calendar 👁️ 65

In today's era of content explosion, when users visit websites, they often hope to quickly find the content they are interested in.Whether it is browsing the vast amount of products on e-commerce platforms or finding housing on websites that meet your preferences, a powerful and easy-to-use filtering and search interface is crucial for enhancing user experience.

AnQiCMS (AnQiCMS) knows this and provides strongarchiveFiltersThe tag can help you easily build complex product or real estate filtering interfaces, making your website content more discoverable and interactive without the need to write complex backend logic.

Understand the core elements of the filter interface

To build an efficient filter interface, we need several core components to work together:

  1. Content model and custom fields: This is the basis of the filtering function. You need to define various filtering attributes in the content model of Anqi CMS backend.For example, for a real estate website, you can define fields such as 'property type' (residential, commercial, apartment), 'area range', 'number of bedrooms', 'renovation status', etc.For a product website, it can be 'color', 'size', 'brand', 'memory size', etc.The key is that these fields need to be set to 'single selection' or 'multiple selection' and other types suitable for filtering, and preset with the values available for selection.These preset values will be directly converted into the front-end filter options.

  2. archiveFiltersThe magic of tags:This label is a filter interface generator. It automatically generates a series of filter options based on the content model and its custom fields.Even better, it will generate a link with the correct URL parameters for each option.When the user clicks on these links, the page will reload, but the URL will carry the filter conditions selected by the user.

  3. archiveListThe response of tags: archiveFiltersGenerated URL parameters will be applied on the same page.archiveListTags will be automatically recognized and applied. This means you don't need to doarchiveListThe label writes complex parameters to handle the filtering logic, it automatically reads the filter conditions from the URL and retrieves the documents that meet these conditions from the database to display.

These three work closely together to form a powerful mechanism that can achieve dynamic filtering without additional development.

Practice: Build the filtering interface step by step.

Now, let's go step by step to see how to build a real estate filter interface in Anqi CMS.

First step: Preparation - define the content model and filter fields.

First, you need to define or edit your content model on the AnQi CMS backend.Assuming we have a content model named "Real Estate". Go to "Content Management" -> "Content Models", click on the "Real Estate" model to edit, and then add some custom fields, such as:

  • Property Type (FieldName:houseType):
    • Field Type: Single selection
    • Default Value: Residence, Shop, Apartment, Villa (one option per line)
  • Bedroom quantity (FieldName:)bedrooms):
    • Field Type: Single selection
    • Default: One bedroom, two bedrooms, three bedrooms, four or more bedrooms
  • Decorating situation (FieldName:)decoration):
    • Field Type: Single selection
    • Default value: Fully decorated, raw, simple decorated

Make sure these fields have been saved and that you have published some documents containing these custom fields under the 'Real Estate' content model.

Step two: Insert into the list page templatearchiveFiltersTag

Next, open the template file you use to display the property list, usually the corresponding to your 'property' content model{模型table}/list.htmlor{模型table}/index.html.

In this template, find the position where you want to place the filter conditions. We can usearchiveFiltersTag to generate a filter. This tag will output a data structure containing all filter options, and we need to iterate through it to build the actual HTML interface.

{# 假设您的房产模型ID是2,请根据实际情况修改 #}
<div>
    <div class="filter-group">
        <h3>房产筛选</h3>
        {% archiveFilters filters with moduleId="2" allText="不限" %}
            {% for item in filters %}
                <ul class="filter-category">
                    <li class="filter-label">{{item.Name}}: </li>
                    {% for val in item.Items %}
                        <li class="filter-option {% if val.IsCurrent %}active{% endif %}">
                            <a href="{{val.Link}}">{{val.Label}}</a>
                        </li>
                    {% endfor %}
                </ul>
            {% endfor %}
        {% endarchiveFilters %}
    </div>

    {# 房产列表将在此处显示 #}
    <div class="property-list">
        {% archiveList archives with moduleId="2" type="page" limit="10" %}
            {% for item in archives %}
            <div class="property-card">
                <a href="{{item.Link}}">
                    {% if item.Thumb %}
                    <img src="{{item.Thumb}}" alt="{{item.Title}}" class="property-thumbnail">
                    {% endif %}
                    <h4>{{item.Title}}</h4>
                    <p>
                        {% archiveDetail houseType with name="houseType" id=item.Id %}
                        <span>类型: {{ houseType }}</span>
                        {% archiveDetail bedrooms with name="bedrooms" id=item.Id %}
                        <span> | 卧室: {{ bedrooms }}</span>
                        {% archiveDetail decoration with name="decoration" id=item.Id %}
                        <span> | 装修: {{ decoration }}</span>
                    </p>
                    <p class="description">{{item.Description}}</p>
                    <span class="views">{{item.Views}} 浏览</span>
                </a>
            </div>
            {% empty %}
            <p>暂无符合条件的房产信息。</p>
            {% endfor %}
        {% endarchiveList %}

        {# 分页导航 #}
        <div class="pagination-container">
            {% pagination pages with show="5" %}
                <ul>
                    <li class="{% if pages.FirstPage.IsCurrent %}active{% endif %}"><a href="{{pages.FirstPage.Link}}">首页</a></li>
                    {% if pages.PrevPage %}
                    <li><a href="{{pages.PrevPage.Link}}">上一页</a></li>
                    {% endif %}
                    {% for item in pages.Pages %}
                    <li class="{% if item.IsCurrent %}active{% endif %}"><a href="{{item.Link}}">{{item.Name}}</a></li>
                    {% endfor %}
                    {% if pages.NextPage %}
                    <li><a href="{{pages.NextPage.Link}}">下一页</a></li>
                    {% endif %}
                    <li class="{% if pages.LastPage.IsCurrent %}active{% endif %}"><a href="{{pages.LastPage.Link}}">尾页</a></li>
                </ul>
            {% endpagination %}
        </div>
    </div>
</div>

In this example:

  • moduleId="2": Replace it with the actual ID of your content model. You can view the model ID in the background "Content Management" -> "Content Model".
  • allText="不限"This is the display text of the 'All' option in the filter conditions.
  • filtersThis isarchiveFiltersThe main variable of the label output, which includes all filterable fields and options.
  • item.Name:Display the custom field name, for example “House Type”, “Number of Bedrooms”.
  • item.FieldName:It is the actual field name of the custom field in the database, for example.houseType.
  • item.ItemsAre all the available filter options under the current custom field.
  • val.LabelIt shows the text of the filter options, for example 'Residential', 'Commercial'.
  • val.Link: The URL to which the option will jump when clicked, which includes the corresponding filter parameters.
  • val.IsCurrentA boolean value used to determine if the current option is selected, making it convenient to add the 'active' style through CSS.

Step 3: Display the filtered results - combinearchiveList

In the above code example, we have already movedarchiveListtags and filters to the same page. When the user clicks on the filter conditions, the page will reload,archiveListThe label automatically reads the filter parameters from the URL and displays documents that meet the criteria from the "Real Estate" model based on these parameters.

For example, if the user clicks on 'House Type: Residential', the URL may change to/fangchan/list.html?houseType=住宅. At this point,archiveListit will automatically understand this parameter and only display properties of the type 'Residential'.

Related articles

How does the `archiveParams` tag display custom field data of the document on the frontend page?

In AnQi CMS, the flexibility of content is one of our core advantages for website operation and content management.In addition to standardized fields such as titles and text, we often need to add specific custom information for different types of content, such as the 'brand', 'model', and 'origin' of products, or the 'author' and 'source' of articles, etc.These custom fields greatly enrich the dimensions of content display, but how to accurately and flexibly present these meticulously entered backend data on the front-end page is an important consideration during template development. At this time

2025-11-08

How to use the `archiveList` tag's `type="related"` feature to display related article recommendations?

On your website, when visitors finish reading an article, if they can see related content in time, it not only can significantly improve the user experience, reduce the bounce rate, but also can effectively increase the page views and stay time on the website.AnQi CMS provides a very convenient tag: `archiveList`,配合其`type="related"` attribute, it can easily realize this function.###

2025-11-08

How to implement the previous/next document function using `prevArchive` and `nextArchive` tags?

When you operate a website, providing a smooth reading experience for users is one of the key factors in enhancing website stickiness.When a user finishes reading a document, if they can easily jump to the previous or next related article, it will undoubtedly greatly increase their stay time on your website.AnQiCMS (AnQiCMS) understands this and provides very intuitive and powerful `prevArchive` and `nextArchive` tags to help you easily implement this feature.

2025-11-08

How to display article title, content, images, etc. on the document detail page using the `archiveDetail` tag?

Manage website content in Anqi CMS, the document detail page is undoubtedly the core position for users to obtain information.How to present each carefully written article, its title, content, images, and various additional information accurately and vividly to the user, this requires the clever use of our `archiveDetail` tag.This tag is specifically designed to display the details of a single document, and its flexible use will help you easily build a feature-rich and smooth experience detail page.

2025-11-08

How to display the associated tags of the `tagList` and implement a tag cloud effect?

## Utilizing AnQiCMS's `tagList` tag, easily implement document association and tag cloud display Tags play a crucial role in website content operations.They can not only help users quickly find the content they are interested in, improve the convenience of site navigation, but also optimize the search engine's understanding of the website's content through keyword aggregation, thereby bringing better SEO performance.AnQiCMS fully considered this requirement, built-in powerful tag features, and provided flexible template tags `tagList`

2025-11-08

How to retrieve and display the details of a specific `tagDetail` tag?

AnQiCMS (AnQiCMS) provides a series of powerful template tags to help website operators efficiently display content.Among them, the `tagDetail` tag is a key tool for obtaining and displaying specific tag details.Whether it is to build a beautiful tag detail page or to refer to related data of tags on other pages, `tagDetail` can provide a flexible and intuitive solution.

2025-11-08

How does the `tagDataList` tag display all document lists under a specific tag?

In Anqi CMS, managing and displaying content, the tag (Tag) is undoubtedly a very practical tool.It can help us organize documents more flexibly, realize multi-dimensional content aggregation, and greatly benefit the improvement of the website's SEO performance and user experience.When we need to display a list of all documents under a specific tag page, or at any location on the website, the `tagDataList` tag is an indispensable tool.###

2025-11-08

How to display the comment list and pagination on the article detail page with the `commentList` tag?

In AnQi CMS, the comment list on the article detail page is an important component for enhancing user interaction and content vitality.To naturally and smoothly display these comments and achieve a friendly pagination experience, we need to cleverly use the `commentList` and `pagination` template tags.Next, let's take a look at how to implement the display and pagination of comments on the article detail page.

2025-11-08