How to use the filtering feature of AnQiCMS to display a document list under specific conditions?

Calendar 👁️ 65

How to allow users to quickly find the information they need while managing a large amount of content in AnQiCMS is one of the key factors in content operation. 幸运的是,AnQiCMS provides powerful filtering features, allowing you to flexibly display document lists based on specific conditions, thereby greatly enhancing the user experience and content retrieval efficiency of the website.

Define your filtering requirements: start from the background content model

To make use of the AnQiCMS filtering feature, you first need to clarify the conditions through which users should search for content.This usually requires you to make some presets in the background content model.AnQiCMS supports a highly flexible content model, you can customize the structure of articles, products, events, and other types of content according to your business needs.

For example, if you operate a real estate website, you may want users to be able to filter housing information based on the type of property (such as residential, commercial), the area (such as the city center, suburbs), and the price range.To implement these filters, you need to go to the "Content Management" menu in the backend and enter the "Content Model" settings.Here, you can edit or create a new content model and add custom fields to it.

It is crucial to choose the appropriate field type when adding custom fields.For example, for 'house type' or 'area', you can choose 'single selection' or 'drop-down selection', and preset all possible options (such as residential, commercial; downtown, suburban areas).'These preset options are the filtering conditions that future users can click to select on the frontend page.Ensure these fields are reasonably defined, which is the basis for the normal operation of the front-end filtering function.

Smartly layout the front-end: utilizingarchiveFiltersBuild a filtering interface with tags

The backend content model settings have been completed, and the corresponding field information has been filled in for your document content. Next, we can use the built-in tags of AnQiCMS in the front-end template of the website to construct the user-visible filtering interface.

The AnQiCMS template system uses syntax similar to Django, wherearchiveFiltersTags are specifically used to generate filtering conditions.This tag will automatically extract the fields and their preset values that can be filtered according to the specified content model, and convert them into clickable links.

Suppose we want to add a filtering feature to the product list page, it is usually used like this in the template filearchiveFiltersTags:

{# 假设我们的产品模型ID是2,并希望筛选条件显示“全部”选项 #}
<div class="filter-section">
    {% archiveFilters filters with moduleId="2" 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 %}
                {# val.IsCurrent 会判断当前选项是否被选中,方便添加样式 #}
                <li class="filter-option {% if val.IsCurrent %}active{% endif %}">
                    <a href="{{val.Link}}">{{val.Label}}</a> {# 输出筛选选项的名称和点击链接 #}
                </li>
                {% endfor %}
            </ul>
        </div>
        {% endfor %}
    {% endarchiveFilters %}
</div>

In this code block,moduleId="2"Specify the content model we want to filter (for example, "product model").allText="不限"Then set the display text for the "All" option in each filter group.archiveFiltersThe tag will return afiltersA variable, it is an array containing multiple filter groups. We iterate through the filter groups in two layersforand the filter options within each group (item) and each group's filter options (valThus, a dynamic filtering interface is generated. Each option'sLinkThe attribute automatically generates a URL with the corresponding filtering parameters,IsCurrentAttributes can help us add highlight styles to the currently selected filter conditions, enhancing the user experience.

Linked display:archiveListTags make the filter results clear at a glance.

When the user clicks on a filter condition on the filter interface, the page will jump to a URL with specific query parameters. At this point, it is necessary toarchiveListThe tag appears, it can intelligently display a list of documents that meet the conditions according to these URL query parameters.

archiveListThe tag is a core tag used to retrieve document lists in AnQiCMS. When you configure it in the template, if the URL contains the parameters generated byarchiveFilters,archiveListThe system will automatically identify and apply these filter conditions.

Here is an example of a document list that combines filtering and pagination features:

<div class="document-list">
    {% archiveList archives with moduleId="2" type="page" limit="10" %}
        {% for item in archives %}
        <div class="document-item">
            <a href="{{item.Link}}">
                <img src="{{item.Thumb}}" alt="{{item.Title}}" class="document-thumb">
                <h3 class="document-title">{{item.Title}}</h3>
                <p class="document-desc">{{item.Description}}</p>
            </a>
            <div class="document-meta">
                {# 假设“房屋类型”是您自定义的字段,可以直接通过item.字段名调用 #}
                <span>房屋类型: {{item.房屋类型}}</span> 
                <span>发布日期: {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
            </div>
        </div>
        {% empty %}
        <p>抱歉,没有找到符合条件的文档。</p>
        {% endfor %}
    {% endarchiveList %}

    {# 分页导航 #}
    <div class="pagination-section">
        {% pagination pages with show="5" %}
            <a class="pagination-link {% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
            {% if pages.PrevPage %}
            <a class="pagination-link" href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a>
            {% endif %}
            {% for page in pages.Pages %}
            <a class="pagination-link {% if page.IsCurrent %}active{% endif %}" href="{{page.Link}}">{{page.Name}}</a>
            {% endfor %}
            {% if pages.NextPage %}
            <a class="pagination-link" href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a>
            {% endif %}
            <a class="pagination-link {% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
        {% endpagination %}
    </div>
</div>

In this example,archiveListSimilarly specifiedmoduleId="2",type="page"It indicates that we want the content to be displayed with pagination,limit="10"It controls displaying 10 documents per page. When the URL has filtering parameters (such as.../products?房屋类型=住宅&区域=市中心),archiveListit will automatically filter the corresponding product documents based on these parameters and cooperate withpaginationLabel to generate the correct pagination link. You can also directly{{item.您自定义的字段名}}call the custom field content in the document to enrich the list display.

Summary

AnQiCMS's filtering function is defined through a flexible content model on the backend and the frontendarchiveFilters/archiveListThe联动 label provides the website with powerful and easy-to-implement content filtering capabilities.From defining filtering dimensions, building a filtering interface to displaying filtering results, the entire process is smooth and highly customizable, effectively helping your users quickly locate the information they need, thereby enhancing the practicality and user satisfaction of the overall website.

Frequently Asked Questions (FAQ)

1. Can I use multiple filter conditions on a single page? How will AnQiCMS handle it?Yes, the AnQiCMS filtering function supports the simultaneous application of multiple filter conditions. When the user selects multiple conditions, archiveFiltersThe tag-generated link will attach all conditions as URL query parameters.archiveListThe tag will automatically parse these parameters and perform an "AND" logical filter, displaying only the documents that meet all selected conditions.For example, if both 'House Type: Residential' and 'Area: Downtown' are selected, only residential listings in the downtown area will be displayed.

How to set a filter condition to be selected by default, or to display a specific filter result when the page is loaded? archiveFiltersThe tag itself will automatically mark the corresponding filter options based on the query parameters of the current URLIsCurrent=true.If you want to display specific filter results when the page is initially loaded, you can directly add the corresponding query parameters to the page URL.

Related articles

How to dynamically display custom parameter fields of articles or products in AnQiCMS?

When building and operating a website, we often need to display more information than just the title and content, such as product models, colors, inventory, or the author, source, and publishing platform of the article.AnQiCMS knows the importance of personalized content display, and therefore provides a highly flexible custom parameter field function, making website content management and frontend display both powerful and convenient.Next, let's delve deeper together on how to make full use of this feature in AnQiCMS, making your website content dynamic.### First Step

2025-11-08

How to display related article recommendations on the AnQiCMS article detail page?

In website operation, the related article recommendation function on the article detail page can not only effectively improve the user's browsing depth within the site, reduce the bounce rate, but also guide users to discover more valuable content, indirectly improving the overall SEO performance of the website.AnQiCMS as a content management system that focuses on efficiency and scalability, provides flexible template tags, making it intuitive and convenient to implement this function. Let's discuss together how to elegantly implement related article recommendations on the article detail page of AnQiCMS.

2025-11-08

How to display the previous and next article links of the current article in AnQiCMS template?

In content operation, providing navigation to the previous and next articles for each article can not only significantly improve the user's reading experience, but also effectively increase the internal links of the website, which is of great benefit to search engine optimization (SEO).AnQi CMS with its flexible template system makes the implementation of this feature intuitive and efficient.By using a short template tag, you can easily integrate this practical navigation mechanism on the article detail page.

2025-11-08

How to display the detailed content of a specified article or product in AnQiCMS?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides an intuitive way to manage and display various types of content.When you want to display a specific article, product details, or any independent content page created through a content model on a website, the core lies in using its powerful template tag features.AnQiCMS refers to the articles, products, and other independently displayed content on the website as 'documents' (archive).

2025-11-08

How to list all Tag tags in the AnQiCMS template?

In Anqi CMS, using the template function to display all Tag tags on the website is an important operation that helps improve content discoverability and website SEO.AnQiCMS as an efficient content management system provides an intuitive and flexible tag (Tag) management mechanism, allowing users to easily list this content in website templates. ### Learn about AnQiCMS's Tag Function In AnQiCMS, tags (Tag) can be seen as topics or keywords that connect different content.They do not follow a strict hierarchical structure like categories

2025-11-08

How to display the description and link of a specific Tag label in AnQiCMS?

In Anqi CMS, a tag is a powerful content organization tool that not only helps you classify content more finely but also optimizes the website's SEO performance and improves the user's browsing experience.Sometimes, you may wish to display not only the name of the tag at a certain position on the website's frontend, but also its detailed description information, or even jump directly to the link related to the content of the tag.This is not a difficult task, Anqi CMS provides flexible template tags, allowing you to easily meet these needs.

2025-11-08

How to retrieve and display the list of documents under a specific Tag label in AnQiCMS?

In Anqi CMS, managing website content, the Tag tag is undoubtedly a very flexible and practical tool that helps us classify different categories and even different model content according to themes, greatly enriching the organization of content and the browsing experience of users.So when we want to display a list of all documents under a specific Tag on a dedicated page, Anqi CMS provides a very intuitive and powerful template tag to help us achieve this goal.### Understanding the role of Tag tags in Anqi CMS Before delving into the code

2025-11-08

How to display the comment list of a document in AnQiCMS and implement pagination?

In Anqi CMS, adding a comment list to the document page and implementing pagination is a key step to enhancing user interaction experience.This can not only let visitors participate in discussions and share opinions, but also brings more vitality to the website content.AnQi CMS provides intuitive and powerful template tags, allowing us to easily implement these features. ### Integrate the comment feature into your document detail page Comment lists and comment forms are typically integrated into the detail page of the document.

2025-11-08