How to handle user prompts when the filtering result is empty when using `archiveFilters` tag?

Calendar 👁️ 68

Optimize AnQiCMS inarchiveFiltersEmpty result prompt of tags, improve user experience

In AnQiCMS template development,archiveFiltersTags are undoubtedly a powerful tool for building flexible content filtering functions.It allows us to provide users with dynamic filtering options based on predefined document parameters, thereby helping them quickly locate the content they are interested in.However, whether the filter options themselves are empty, or the user applies filter conditions and does not find matching content, if these two 'empty result' states are not handled properly, they may lead to a decline in user experience.As an experienced website operations expert, I know that clear and friendly user prompts are crucial for retaining visitors and improving website usability.

This article will delve into the use ofarchiveFiltersHow to elegantly handle various situations where the filtering results are empty, and provide practical code examples to help you optimize the user experience of your website.

UnderstandingarchiveFiltersLabel and its working principle

First, let's reviewarchiveFiltersThe core function of the tag. It is mainly used on the document list page or model home page, to generate a series of clickable filtering conditions based on the custom fields of the content model.When you call in the templatearchiveFiltersWhen a tag is used, it returns a variable containing all the filter groups (for examplefilters). Each filter group contains all the optional values under the parameter and their corresponding links.

The basic structure is usually as shown below:

{% archiveFilters filters with moduleId="1" allText="全部" %}
    {% for item in filters %}
        {# ... 渲染单个筛选组(如“房屋类型”、“价格区间”)... #}
        {% for val in item.Items %}
            {# ... 渲染筛选值(如“住宅”、“公寓”)及其链接 ... #}
        {% endfor %}
    {% endfor %}
{% endarchiveFilters %}

This is something that needs to be noted,filtersA variable is an array object that contains multiple filter groups(item)。EachitemAlso contains aItemsarray to list specific filter values.

Scenario one: No filter conditions available (filtersThe variable is empty)

Imagine, the user comes to your website with high expectations, wanting to filter content based on various conditions, only to find that the filter area is empty, with no options to choose from.This will undoubtedly confuse them, and they may even mistakenly think that the website function is missing.

This situation usually occurs when you have configured a content model forarchiveFiltersBut no custom fields defined for filtering or no matching filtering data in the current context lead toarchiveFiltersthe tags returned byfiltersThe variable itself is an empty array.

Solution:

AnQiCMS template engine (similar to Django template) providesfor...emptysyntax, which is the tool for handling the 'empty list' situation. You canforAdd one inside the loop{% empty %}block, whenfiltersThe content inside this block will be rendered when the array is empty.

<div>
    <h3>筛选条件:</h3>
    {% archiveFilters filters with moduleId="1" allText="全部" %}
        {% for item in filters %}
            <ul class="filter-group">
                <li class="filter-name">{{ item.Name }}: </li>
                {% for val in item.Items %}
                    <li class="filter-item {% if val.IsCurrent %}active{% endif %}">
                        <a href="{{ val.Link }}">{{ val.Label }}</a>
                    </li>
                {% endfor %}
            </ul>
        {% empty %}
            <p class="no-filters-message">抱歉,当前暂无筛选条件可供选择。</p>
        {% endfor %}
    {% endarchiveFilters %}
</div>

In this way, when there are no filter conditions, users will see a clear prompt message instead of a blank area, which greatly enhances the user friendliness.

Scenario two: No matching documents after filtering (archiveListis empty)

Another common situation is that the filtering conditions themselves exist, and users have actively selected some conditions (such as selecting

In this case,archiveFiltersThe tag may have normally rendered the filter options, but then used to display the document list.archiveListThe tag, however, found that itsarchivesvariable is empty.

Solution:

Is similar to handling an empty filter condition,archiveListTags also supportfor...emptySyntax. You can use it to render document lists.forLoop added{% empty %}Block, so that a friendly prompt is displayed when no matching document is found.

<div>
    <h3>筛选结果:</h3>
    {% archiveList archives with type="page" limit="10" %}
        {% for item in archives %}
            <div class="document-item">
                <a href="{{ item.Link }}">
                    <h4>{{ item.Title }}</h4>
                    <p>{{ item.Description }}</p>
                </a>
            </div>
        {% empty %}
            <div class="no-results-message">
                <p>抱歉,没有找到符合您筛选条件的文档。</p>
                <p>请尝试调整筛选条件,或许能找到您感兴趣的内容。</p>
                {# 提供一个清除所有筛选条件的链接,帮助用户快速重置 #}
                <a href="{{ urlParams.clearLink }}" class="btn-clear-filters">清除所有筛选</a>
            </div>
        {% endfor %}
    {% endarchiveList %}
    {# 确保分页标签只在有内容时显示,避免空列表下的分页混乱 #}
    {% if archives %}
        <div class="pagination-area">
            {% pagination pages with show="5" %}
                {# ... 分页链接渲染 ... #}
            {% endpagination %}
        </div>
    {% endif %}
</div>

In this example, we not only provided the "not found" prompt, but also offered suggestions (such as "adjust the filtering conditions") and a real

Related articles

How to design UI/UX for the `archiveFilters` tag when there are many filtering conditions to keep it clear and easy to use?

As an experienced website operations expert, I know that an excellent CMS system not only needs to provide strong backend functions but also needs to present the ultimate user experience on the front end.AnQiCMS (AnQiCMS) demonstrates tremendous potential with its high-performance architecture based on the Go language and flexible template tag system.Today, let's delve deeply into how to maintain a clear and easy-to-use page through clever UI/UX design when there are many document filtering conditions in Anqi CMS (implemented through the `archiveFilters` tag).

2025-11-06

How to add independent titles or descriptions to each filter group of the `archiveFilters` tag?

As an expert in the operation of AnQiCMS, I am happy to answer your question about how to add independent titles or descriptions to each filter group in the `archiveFilters` tag.This can greatly enhance the user experience and make the website's filtering function more intuitive and friendly.

2025-11-06

Does AnQi CMS plan to enhance the intelligent recommendation filtering function of the `archiveFilters` tag in future versions?

As an experienced website operations expert, I have accumulated rich experience in the practice of content management systems (CMS), especially in understanding the various functions and content operation strategies of AnQiCMS (AnQi CMS).Today, we will discuss a topic that many content operators and website developers are concerned about: Does AnQi CMS plan to enhance the intelligent recommendation filtering function of the `archiveFilters` tag in future versions??### `archiveFilters` tag's current capability analysis

2025-11-06

Does the `archiveFilters` tag automatically handle existing URL parameters when generating filter links to avoid conflicts?

## The `archiveFilters` tag of AnQi CMS: Harmonious Coexistence of Intelligent Filtering Links and URL Parameters In today's information explosion in the network world, the richness and interactivity of website content are crucial for attracting and retaining users.For corporate websites, vertical industry portals, or content-rich self-media platforms, how to allow users to quickly and accurately find the information they need is an eternal challenge.AnQi CMS deeply understands this, its powerful template tag system provides many solutions for it

2025-11-06

Does the `archiveFilters` tag support controlling the sorting method for custom parameters?

As an experienced website operations expert, I have a deep understanding of AnQiCMS's functional and content operation strategies.Today, we will discuss a question that many users may be concerned about: Does the `archiveFilters` tag support controlling the sorting method of custom parameters?

2025-11-06

How will the `archiveFilters` tag display and handle if a document belongs to multiple filter parameter values?

## AnQi CMS `archiveFilters` tag: How will it elegantly present when a document meets multiple filter conditions?As an experienced website operations expert, I am well aware that the discoverability of content is crucial for user experience and SEO.AnQiCMS provides many powerful and flexible features in content management, among which the `archiveFilters` tag is undoubtedly a powerful tool for building advanced filtering interfaces and improving content navigation efficiency.

2025-11-06

`archiveFilters` label can be combined with AnQiCMS's multilingual support to provide multilingual filtering conditions?

As an experienced website operations expert, I have accumulated rich experience in the content management and operations practice of AnQiCMS.Today, we will delve into a commonly discussed issue by users: Can AnQiCMS's `archiveFilters` tag be combined with multilingual support to provide multilingual filtering conditions?To answer this question, we need to understand the multilingual mechanism of AnQiCMS and the working principle of the `archiveFilters` tag.AnQiCMS as an enterprise-level content management system

2025-11-06

How to use the `archiveList` tag of AnQiCMS to get the document list under a specified content model?

AnQiCMS Content Management: The secret to accurately obtaining the document list with the `archiveList` tag As an experienced website operations expert, I know that the core value of a content management system (CMS) lies in its ability to organize and display content.In the AnQiCMS, this efficient and flexible Go language content management system, the `archiveList` tag is undoubtedly a powerful weapon in the content display process.It is not just a simple content call tag, but also a key bridge connecting your website content model with the front-end display logic.

2025-11-06