How to implement filtering conditions based on document parameters and display the filtering results?

Calendar 👁️ 60

In AnQiCMS (AnQiCMS), using document parameters to build flexible filtering conditions and display the filtering results is a key factor in improving website user experience and content management efficiency.This not only helps users find the information they need faster, but also makes the website content structure clearer.This article will introduce you to implementing this feature in Anqi CMS, from the initial parameter definition to the final filtering display, helping you easily manage content.

How to cleverly use document parameters to implement filtering function in Anqi CMS to make content smarter

With the continuous enrichment of website content, how to help visitors quickly and accurately find the information they are interested in has become a common challenge for website operators.An enterprise CMS with its flexible content model and powerful template tag features provides us with an elegant solution - by building filters through custom document parameters.Imagine, a real estate website can filter housing listings based on conditions such as 'house type', 'area', and 'region', and an e-commerce platform can filter products based on attributes such as 'color', 'size', and 'brand'. All of this relies on the clever use of document parameters.

Let's uncover the mysterious veil of implementing this function in Anqi CMS step by step.

One, preparation work: define document parameters

To implement the filter function, you first need to define the filtering parameters for your content.One of the core advantages of AnQi CMS is its flexible content model, which is the foundation for our implementation of the filtering function.

  1. Enter content model management:Log in to the Anqi CMS backend, navigate to the 'Content Management' menu, and find the 'Content Model' option.Here, you can manage and edit the model used for various types of content on your website (such as articles, products, etc).
  2. Edit or create a new content model:Select an existing content model that you want to add filtering functions to for editing, or create a new content model.
  3. Add custom field:In the content model editing interface, you will see the "Content Model Custom Field" area.Click "Add field" to define filtering parameters for your content.Here, the key is to choose an appropriate field type, especially the types of single-choice, multiple-choice, and dropdown, which are very suitable as filtering conditions.
    • Parameter name:This is the field name displayed to the user on the front end, such as "type" or "color".
    • Call field:This is the unique identifier used to refer to the parameter in the template code, please use letters, such as 'houseType', 'color'.
    • Field type:Select "Single Choice", "Multiple Choice", or "Dropdown".
    • Default:Enter the option values to be filtered, one per line. For example, if the 'type of house' field has options such as 'one-bedroom', 'two-bedroom', etc., enter them separately in the default value area.These values will be directly used as clickable filters for users.

After defining the field, remember to save the content model. Next, when publishing or editing documents, you can fill in the values for these custom fields.These values will serve as attributes of the document, becoming the target of future filtering.

Second, build the filter interface: usearchiveFiltersTag

With defined document parameters, the next step is how to present these parameters on the front-end page so that users can select filtering conditions. Anqi CMS provides specialarchiveFiltersLabel to help us automate the construction of this complex filtering interface.

  1. Determine the label placement position: archiveFiltersLabels are usually placed on the document list page or the home template of the document model, which is the page where users need to filter the content when browsing.
  2. UsearchiveFiltersTags:This label can automatically read the custom fields of the content model you define in the background and generate the corresponding filter link. It mainly needs amoduleIdParameters to specify which document of the content model you want to filter.
    • moduleId: Specify the content model ID of the document you want to filter. For example,moduleId="1"may represent the article model,moduleId="2"May represent a product model. You can find the corresponding ID on the content model management page.
    • allText: Used to set the display text for default options such as 'All' or 'Unlimited', if you do not want to display this default option, you can set it tofalse.

Here is a simple code example demonstrating how to usearchiveFilterstags to create a filter:

{# 假设我们正在为一个ID为1的内容模型(如文章)创建筛选器 #}
<div class="filter-section">
    <div class="filter-title">参数筛选:</div>
    {% 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-option {% if val.IsCurrent %}active{% endif %}">
                <a href="{{val.Link}}">{{val.Label}}</a> {# 生成带有筛选参数的URL链接 #}
            </li>
            {% endfor %}
        </ul>
    {% endfor %}
    {% endarchiveFilters %}
</div>

In this example,filtersis an array containing all filterable parameters.item.NameIt will display the parameter name you set in the background (such as "house type"),item.Itemswhich is an array containing all the options of the parameter. For each option,val.LabelIt is the text displayed to the user (such as "One-bedroom"), whileval.Linkit is the complete URL automatically generated by the Anqi CMS, which includes the full filtering conditions.val.IsCurrentIt is used to determine whether the current option is selected, convenient for you to add styles.

3. Display filtering results: archiveListusefulness

After the user clicks the filter conditions, the page needs to dynamically display the corresponding document list based on these conditions. Anqi CMS'sarchiveListThe tag plays a core role here, as it can intelligently capture the filtering parameters in the URL and query the database accordingly to return documents that meet the criteria.

  1. archiveListAutomatically respond to filtering conditions: archiveListThe tag does not need any additional settings to "receive" filtering parameters. WhenarchiveFiltersThe generated link, when clicked, will contain parameters similar to?houseType=one_bedroom&color=redsuch as query parameters.archiveListThe tag will retrieve data, it willAutomatically identify and applyThe parameters in these URLs are used as filtering conditions.
  2. Combined with pagination function:To better manage the filtered results, we usually combine pagination tagspaginationtogether.archiveListlabel'stype="page"The parameter indicates enabling pagination functionality.

Here is a complete code example combining the filter with the document list and pagination features.

`twig {# Filter

Related articles

How to display custom parameters on an article or product detail page?

In website operation, adding personalized information to articles or product detail pages is the key to improving content professionalism and user experience.AnQiCMS (AnQiCMS) fully understands this need and provides powerful customizable parameter functions, allowing us to flexibly add and display the required information according to different content types. Imagine you publish a technical article, in addition to the title and content, you also want to display unique attributes such as "author", "publish date", "technology stack", and so on; Or maybe, you are selling a product, in addition to the usual name, price, and description, you also want to highlight the "color"

2025-11-08

How to display a list of related articles below the article detail page?

In website operation, the list of "related articles" at the bottom of the article detail page is an important function to enhance user experience, increase page views (PV), and prolong the time users stay on the site.It can guide users to discover more interesting content, thereby enhancing the overall stickiness of the website, and also has a positive effect on search engine optimization (SEO).To implement this feature in AnQi CMS, it benefits from its flexible template system and powerful tag functions, making the entire process intuitive and efficient.### One, understand the call mechanism of "related articles" The template tags of AnQi CMS are the core of realizing various functions

2025-11-08

How to display the links to the previous and next articles on the document detail page?

When browsing website content, users often want to be able to navigate easily between related articles.For example, after reading a news article or tutorial, you can quickly click to go to the "previous" or "next" article to maintain the continuity of reading.This not only improves user experience and reduces the bounce rate, but also has a positive effect on the internal link structure of the website and search engine optimization (SEO).AnQiCMS (AnQiCMS) is an efficient content management system that provides a very simple and intuitive way to implement this function.We do not need complex backend programming

2025-11-08

How to display mathematical formulas and flowcharts with Markdown in AnQiCMS?

In content operations, sometimes we need to display complex mathematical formulas or clear flowcharts, especially in technical articles, data reports, or educational content.AnQiCMS with its powerful Markdown editor, provides us with the convenience to meet this requirement.By simple configuration and importing the necessary library files, you can perfectly present these professional contents on the website front-end.### Enable AnQiCMS Markdown Editor Firstly, let AnQiCMS recognize and handle Markdown formatted content

2025-11-08

How to display a list of commonly used tags on a website or tags of specific documents?

In AnQiCMS, efficiently manage and display website tags, which can not only help users find the content they are interested in faster, but also effectively improve the SEO performance of the website.Tags as a flexible content classification method can associate content spanning different categories and even different models, forming a content matrix.Below, we will start from several common application scenarios and explain in detail how to display the list of commonly used tags on your website, as well as how to display associated tags for specific documents.### The Importance of Tags Tags are a powerful content management tool in AnQiCMS

2025-11-08

How to retrieve and display detailed descriptions and associated documents for a specific tag?

In content management, tags are a powerful and flexible tool that helps us organize website content more finely, improve user experience, and optimize search engine rankings.AnQiCMS fully understands this, providing intuitive and feature-rich template tags that allow you to easily obtain and display detailed descriptions of specific tags and their associated documents.This article will delve into how to use these tags in the AnQiCMS template to make your website content more relevant and discoverable.### Understand the tags in AnQiCMS In

2025-11-08

How to display the user comment list below the article page?

In website operation, user comments are an important aspect for enhancing content interaction, strengthening community atmosphere, and optimizing search engine rankings (SEO).AnQiCMS provides a flexible and powerful template tag system, making it easy and convenient to integrate a user comment list and comment form at the bottom of the article page.This article will provide a detailed introduction on how to elegantly display user comments on the article detail page of AnQi CMS, and also provide a function for users to submit comments.

2025-11-08

How to integrate and display a friend link list on a website?

In website operation, friendship links play an indispensable role. They are not only the bridges to establish contact with other websites but also effective ways to improve website authority, obtain external traffic, and enhance user experience.AnQiCMS as an efficient and flexible content management system provides an intuitive and convenient solution for the integration and display of friend links. ### First Part: Admin Friend Links One of the design philosophies of AnQiCMS is to make website operation more efficient, and the management of friend links is naturally integrated very well.

2025-11-08