How can the display content of the document list be dynamically adjusted through filtering conditions?

Calendar 👁️ 66

AnQiCMS (AnQiCMS) provides website operators with powerful content management capabilities, one very practical feature of which is the ability to dynamically adjust the display content of document lists through filtering conditions.This not only greatly enhances the user experience, helps visitors quickly find the information they need, but also optimizes the internal link structure of the website, indirectly helping search engine optimization (SEO).

Imagine if your website is rich in content, but every time the user searches for specific information, they can only do so through cumbersome pagination or a single keyword search, which is undoubtedly frustrating.The dynamic filtering feature is like equipping your website content with an intelligent navigation system, where users can click a few times to accurately filter out the document lists they are most interested in, making the content presentation more intelligent and personalized.

Core mechanism:联动 of document list tags and filters

The AnQi CMS achieves this feature mainly by relying on its powerful template tag system, especiallyarchiveList(Document list tag) andarchiveFiltersthe clever cooperation of (document parameter filter tags).

archiveListIt is the core tool you display in the template, which itself supports various basic filtering and sorting parameters, such as:

  • moduleIdSpecify which content model document to display (such as article model or product model).
  • categoryIdLimit the search to a specific category or multiple categories.
  • flagBased on recommended properties (such as headlines, recommendations, sliders, etc.) to filter.
  • orderDefine the sorting method of documents, such as by the most recent published, views, etc.
  • qUsed for keyword search, to achieve fuzzy matching.
  • limitControls the number of documents displayed per page, used in conjunction with pagination tags.

These parameters can already meet the needs of most list display. However, when you need more detailed and multi-dimensional filtering, such as filtering by product color, house type, or article theme,archiveFiltersLabels came into being.

Build multi-dimensional filtering: start from the content model

To implement custom dynamic filtering, the first step is to prepare in the Anqi CMS backend content model.

The content model is the flexibility of Anqi CMS, which allows you to define exclusive fields for different types of content (such as articles, products, cases, etc).When you need to filter by specific conditions, you need to create a "custom field" in the corresponding content model.

For example, you operate a real estate website and hope that users can filter housing resources according to conditions such as 'house type', 'area range', 'orientation', etc. You can add these fields to the 'housing model':

  • Room type: Field type can be either 'Single selection' or 'Dropdown selection', and preset options such as 'One bedroom apartment', 'Two bedrooms apartment', etc.
  • Area range: Field type can be 'number', allowing users to enter a range.
  • Orientation: Field type can be 'single selection', with preset options such as 'south', 'north', etc.

These custom fields are exactlyarchiveFiltersthe source of the label to get the filter conditions.

Create a filter interface in the template

After defining the fields in the content model, the next step is to use them in the front-end template,archiveFiltersThe tag is used to generate a filtering interface. This tag is usually used on document list pages or the document homepage.

archiveFiltersThe label automatically parses the custom fields supported by the current content model and generates a corresponding list of filter options. It provides several key parameters:

  • moduleIdSpecify which model's filter to retrieve (witharchiveListofmoduleIdmaintain consistency).
  • allTextDefine the display text for default options like 'All' or 'Unlimited'.
  • siteIdIf you use the multi-site feature, you can specify a filter to retrieve a specific site.

WhenarchiveFiltersThe label is executed when it returns a variable containing all the filter groups (corresponding to the custom fields you define).Each filter group also includes multiple filter options (corresponding to the options you set for the field).It is most important that each filter option will automatically generate a URL link with the corresponding filter parameters.

For example, a segment usingarchiveFiltersmay look like this:

{# 假设这是房产列表页,moduleId=10代表房源模型 #}
<div>
    <h3>筛选房源</h3>
    {% archiveFilters filters with moduleId="10" allText="不限" %}
        {% for filterGroup in filters %}
            <div class="filter-group">
                <span>{{ filterGroup.Name }}:</span> {# 例如:户型、朝向 #}
                <ul>
                    {% for option in filterGroup.Items %}
                        <li class="{% if option.IsCurrent %}active{% endif %}">
                            <a href="{{ option.Link }}">{{ option.Label }}</a> {# 例如:一室一厅、朝南 #}
                        </li>
                    {% endfor %}
                </ul>
            </div>
        {% endfor %}
    {% endarchiveFilters %}
</div>

This code dynamically generates a series of filter links, for example, after clicking "One bedroom one living room", the page URL may change to/fangyuan/list.html?huxing=yishiyiting.

Dynamic matching of document list and filter results

Once a user clicks on a filter link, the page URL will include the corresponding filter parameters (for examplehuxing=yishiyiting)。At this point, the amazing thing isarchiveListThe tag can intelligently identify and automatically apply these parameters in the URL to adjust the display content of the document list.

You do not need toarchiveListManually parse URL parameters in the tag. Just make surearchiveListoftypethe parameter topage(Indicates enabling pagination functionality, usually combined with filtering and searching), it will automatically be linked witharchiveFiltersthe generated link perfectly.

For example, the code to display the listing of properties:

{# 房源列表部分 #}
<ul class="house-list">
    {% archiveList houses with moduleId="10" type="page" limit="12" %} {# type="page"是关键 #}
        {% for item in houses %}
            <li>
                <h4><a href="{{ item.Link }}">{{ item.Title }}</a></h4>
                <p>{{ item.Description }}</p>
                {# 这里还可以显示自定义字段,例如 item.huxing, item.chaoxiang #}
                <p>户型: {{ item.huxing }}</p>
            </li>
        {% empty %}
            <li>暂无符合条件的房源。</li>
        {% endfor %}
    {% endarchiveList %}
</ul>

{# 分页部分 #}
<div class="pagination">
    {% pagination pages with show="5" %}
        {# 渲染分页链接,这些链接也会自动带上筛选参数 #}
        {% for pageItem in pages.Pages %}
            <a href="{{ pageItem.Link }}" class="{% if pageItem.IsCurrent %}active{% endif %}">{{ pageItem.Name }}</a>
        {% endfor %}
    {% endpagination %}
</div>

After the user clicks the filter link for "One Bedroom One Living Room,"archiveListwill automatically filter according to thehuxing=yishiyitingthe parameter will only show housing units with "One Bedroom One Living Room". At the same time,paginationThe pagination links generated by the tags will also automatically include these filtering parameters, ensuring that the filtering conditions are still valid when the user navigates through pages.

Integration of search and filtering

In addition to custom filtering, you can also combine the keyword search function with dynamic filtering.archiveListlabel'sqThe parameter is designed for this. When the URL contains at the same timeq=关键词and custom filter parameters,archiveListIntelligently combine the two to provide more accurate search results.

The importance of pseudo-static rules.

It is crucial to configure appropriate rewrite rules to make these dynamically generated filter URLs more aesthetic and SEO-friendly. Anqi CMS provides flexible rewrite rule options, allowing you to set the URL structure as needed, for example, to/fangyuan/list.html?huxing=yishiyitingbe beautifulized/fangyuan/huxing-yishiyiting/This not only improves the user experience, but also makes it easier for search engines to understand the theme and structure of the page.

Through the above mechanism, AnQi CMS makes the dynamic filtering and display of website content simple and efficient.The operator only needs to define the content model and fields in the background, and reasonably call the tags in the template, so as to provide users with a highly customizable and friendly content browsing experience, thereby enhancing the professionalism and attractiveness of the website.


Frequently Asked Questions (FAQ)

  1. Can dynamic filtering conditions be used at the same time as normal keyword search?Of course. Anqi CMS'sarchiveListThe tag is very intelligent, it will simultaneously identify and apply custom filtering parameters in the URL (byarchiveFiltersgenerated) and keyword search parameters (qParameter). This means that the user can first filter out listings with "one bedroom and one living room", and then search for listings containing "school district houses" among these results, and the system will handle these query conditions together.

  2. If I defined custom fields in the content model butarchiveFiltersthese fields are not displayed what should I do?First, please check the `archiveFilters

Related articles

How to display banner carousel images or thumbnails on the category page to enrich the visual effects?

In website operation, the category page is not just a content directory, but also a key entry for users to explore and discover your website's services or products.A beautifully designed, visually rich category page can significantly enhance user experience, inspire their interest, and guide them to explore deeper.AnQiCMS (AnQiCMS) provides flexible and powerful features, allowing you to easily display eye-catching banner carousel images or beautiful thumbnails on the category page, thereby enriching the visual effects and attracting visitors' attention.###

2025-11-08

How can I specify a display template uniformly for all documents under a specific category?

When using AnQiCMS to manage website content, we often encounter such a need: we hope that all articles, products, or other documents under a specific category can be unified to use the same display template, rather than setting each document separately.This not only ensures the consistency of the website style, but also greatly improves the efficiency of content operation.AnQiCMS knows the pain points of users in this regard, and therefore provides a very flexible and intuitive setting method to meet this need.### Target Classification First, we need to enter the AnQiCMS admin interface

2025-11-08

Can the settings of the category template be inherited by subcategories to unify the display style of subcategories?

It is crucial to maintain the consistency of page style in website content management to enhance user experience and brand image.Especially for websites with multi-level categories, how to efficiently manage the display styles of these category pages is a concern for many content operators.AnQiCMS (AnQiCMS) provides very practical functions in this aspect, which can help us easily achieve the uniformity of the display style of subcategories.Understanding the importance of category templates and subcategory inheritance in Anqi CMS

2025-11-08

How to set a custom template for categories to change the overall display style of the category page?

AnQi CMS provides great flexibility for website content management, and customizing the display style of category pages is a very practical feature.By setting custom templates for different categories, you can easily allow news, products, cases, and other types of category pages to present unique design and content layouts, thereby better meeting users' browsing needs and brand display strategies.Why do you need a custom category template? By default, AnQi CMS uses a generic list template for all categories (usually `{modeltable}/list.html`)

2025-11-08

How does the AnQiCMS recycle bin feature affect the display status and recovery of deleted content?

In the operation of daily websites, content management often comes with the risk of accidental operations, whether it is the accidental deletion of important articles or content that needs to be recalled after publication.A comprehensive content management system should not only provide efficient publishing tools but also have a reliable security mechanism.A safe CMS knows this and therefore provides a thoughtful trash can function, which plays a crucial role in content lifecycle management.### SecureCMS Recycling Station: Safe Harbor When you perform deletion operations on articles, products, pages, and other content in the SecureCMS backend

2025-11-08

How to extend the content model through custom fields and display this additional information on the frontend page?

In AnQi CMS, the presentation of content is not limited to basic elements such as title and body.To meet the diverse content display needs of corporate websites, the system provides powerful content model custom field functions, allowing us to add various exclusive information according to specific business scenarios.This is like customizing a detailed profile for each content type, which is not only clear in backend management but also flexible on the frontend page, greatly enhancing the website's performance and user experience.Why do we need custom fields?

2025-11-08

How does AnQiCMS handle remote images and display them as locally optimized versions?

In website content operation, images play a crucial role.They not only enrich the content and attract readers, but are also an indispensable part of search engine optimization (SEO).However, when our content contains a large number of images from external links, how to efficiently and optimally handle these remote images and convert them into the local advantages of our website has become a problem that needs to be solved.Luckyly, AnQiCMS provides very practical and powerful functions in this aspect, allowing us to easily achieve the localization and optimization of remote images.### The localization of remote images

2025-11-08

How to enable Webp image format to optimize image loading and display speed?

The loading speed of a website is one of the key factors in user experience and search engine optimization.Among many optimization methods, image optimization plays a crucial role.Image files often occupy a large part of the web page loading content, and if not handled properly, they can significantly slow down the website's response time.Luckily, AnQiCMS (AnQiCMS) provides support for WebP image format, which is an efficient image format that can significantly improve the loading and display speed of website images.What is the WebP image format?

2025-11-08