In-depth analysis of AnQi CMSarchiveFiltersLabel: Does it support numeric range filtering?
As an experienced website operations expert, I am well aware of the importance of the flexibility of the filtering function in a content management system for user experience and content presentation.AnQiCMS (AnQiCMS) is favored in the content management field for its efficiency and customizable features.archiveFiltersEspecially regarding whether it supports filtering based on numerical ranges, such as the need for 'price range' or 'date range'.
archiveFiltersThe design philosophy and core functions of tags
First, let's understandarchiveFiltersThe positioning of tags in Anqi CMS. According to the official documentation,archiveFiltersThe label is mainly used for making list combination filtering conditions based on various document parameters.The original design was to facilitate website administrators to generate a set of predefined, discrete filtering options based on custom fields defined in the content model.For example, on a real estate website, you can filter by predefined categories such as 'house type' (residential, commercial) or 'house size' (single room, one bedroom and living room).
In the template, we usually use it like thisarchiveFilters:
{% archiveFilters filters with moduleId="1" allText="全部" %}
{% for item in filters %}
{# 遍历每个筛选维度,如“房屋类型” #}
<ul>
<li>{{item.Name}}: </li> {# 显示维度名称,如“房屋类型” #}
{% for val in item.Items %}
{# 遍历该维度下的具体选项,如“住宅”、“商铺” #}
<li class="{% if val.IsCurrent %}active{% endif %}"><a href="{{val.Link}}">{{val.Label}}</a></li>
{% endfor %}
</ul>
{% endfor %}
{% endarchiveFilters %}
From the above structure, we can see,archiveFiltersthe tags returned byfiltersA variable is an array object containing multiple filtering dimensions. Eachitemrepresents a filtering dimension, which hasName(parameter name),FieldName(parameter field name) andItems(optional values) and other properties. WhileItemsEach in the arrayvalalso includesLabel(Filter value),Link(Filter link) andIsCurrent(Whether selected) and other information. This clearly indicates,archiveFiltersThe core mechanism is to generate a set of predefined, discrete options for each custom field, and to generate corresponding filter links for these options.
archiveFiltersDoes it directly support numeric range filtering?
Directly answer this question:Currently, the Anqi CMS isarchiveFiltersThe tag does not directly support filtering based on numerical ranges (such as "price range" or "date range") in its original design.
This means that you cannot simply pass inarchiveFiltersto the tag.min_price/max_priceorstart_date/end_dateThis parameter, and expect it to automatically generate a filter interface containing range logic.This label is more focused on providing a set of preset options that users can click to select, each corresponding to a specific, discrete value.
For example, if you define a namedpricecustom field of the "numeric" type in the background content model,archiveFiltersIt will not automatically provide a slider or input box for the user to enter the minimum/maximum price for filtering. Instead, it will expect you topriceDefine a series of discrete 'price range' options (such as: 0-100 yuan, 101-500 yuan, 501-1000 yuan), and then generate filter links for these options.
How to implement a similar numerical range filter in Anqi CMS?
AlthougharchiveFiltersThe tag itself does not directly handle the range, but the flexibility of Anq CMS and its powerful template engine still provides ways to achieve similar effects.
Defined by the background pre-defined discrete intervals:This is the most direct and conforms to
archiveFiltersThe method of design ideas.For numeric fields (such as price) or date fields (such as publication year) that require range filtering, you can pre-set the filtering options for these fields as discrete intervals in the content model on the backend.- Price range:Add custom options for the "Price
archiveFiltersThese options will generate clickable filter links, allowing users to select preset price ranges by clicking. - Date range:Similarly, you can define discrete options such as 'last week', 'last month', 'this year', 'last year', etc. for the 'publish date' field.This method sacrifices some dynamics, but it has already been able to meet the needs of users to filter through predefined conditions for most business scenarios.
- Price range:Add custom options for the "Price
Combine front-end custom logic and backend parameter processing (advanced implementation):For scenarios where users need to input specific numbers (such as using a slider to select a price range) or select an exact date range through a date picker, this will require more in-depth custom development:
- Front-end interaction:You need to write custom HTML form elements in the front-end template (such as
input type="range"sliders,input type="date"Date picker) and JavaScript code. These frontend codes are responsible for capturing user input and dynamically building URL query strings that include range parameters, such as?price_min=100&price_max=500Or?start_date=2023-01-01&end_date=2023-12-31. - Backend parameter processing:Of Security CMS
archiveListThe tag is intype="page"In this mode, it supports custom filtering through URL query parameters (as mentioned in the documentation)q="搜索关键词"or custom filtering parameterssex=男)。Therefore, if your content model containspriceorcreated_timesuch numeric or date fields, theoretically, when users submit through the front endprice_minandprice_maxWhen the parameters are given, the backend can perform range queries at the database level according to these parameters.This requires the backend to have corresponding logic to parse these custom range parameters and convert them into database query conditions.archiveFiltersThe tag does not generate these complex links with range parameters, but it does not prevent you from building a more powerful range filtering system through custom front-end and back-end logic.
- Front-end interaction:You need to write custom HTML form elements in the front-end template (such as
Summary
Of Security CMSarchiveFiltersTags are an efficient and intuitive tool for filtering content based on predefined discrete options.It converts the custom fields from the backend into interactive filters on the frontend using a concise template syntax.However, the native function does not support direct numerical or date range filtering.To implement such advanced filtering, you can meet common needs by presetting discrete intervals in the background, or by combining custom frontend interaction and backend parameter processing to build a more flexible and dynamic solution.This demonstrates that AnQi CMS provides basic easy-to-use functions while also retaining sufficient extensibility to deal with complex business scenarios.
Frequently Asked Questions (FAQ)
1. WhyarchiveFiltersTags do not support direct numeric range filtering?
archiveFiltersThe design intention of the tag is to convert predefined, discrete custom field options in the content model (such as "house type" or "region") into front-end filters. It achieves filtering by generating an independent link for each preset option.