As an experienced website operations expert, I am well aware of the importance of the flexibility of a content management system (CMS) for efficient operations, and AnQiCMS, with its powerful content model customization capabilities, has provided us with great convenience in this regard. Today, let's delve into a common concern: the features of AnQiCMS'sarchiveFiltersDoes the tag support filtering user-defined "content model custom fields"?
Foundation of AnQiCMS content model and custom fields
First, let's briefly review one of the core advantages of AnQiCMS in content management:Flexible content model.In AnQiCMS, the content model is not just articles or products such as predefined categories.It allows operators to create highly personalized content structures such as "real estate information", "course lists", and "software functions" based on their business needs.Custom field.
For example, you may add fields such as 'house type', 'area', 'region', 'decoration condition', etc. to the 'Real Estate Information' model; add fields such as 'course level', 'teacher', 'class start time', etc. to the 'Course List'.These custom fields greatly enrich the expression of content, allowing the website to carry more diverse and targeted information.But after the content is rich, how to make it easy for users to find the content they are interested in has become a key operational challenge.This is when the content filtering function becomes particularly important.
RevelationarchiveFiltersTags: more than just built-in fields
When it comes to content filtering, AnQiCMS'sarchiveFiltersTags are indispensable tools in template development.At first glance, we might think it is mainly used to filter some built-in common properties.archiveFiltersThe power of tags goes far beyond this, as it fully supports deep integration with user-defined content model fields, thereby generating highly customized filtering interfaces.
This tag's core function isGenerate a series of filtering conditions based on document parametersIt will traverse the fields you have configured as 'filterable' in the background content model, and generate corresponding filter options and links for the preset values of these fields. This means,archiveFiltersThe tag does not directly receive custom field names as parameters for filtering operations, but it can intelligently recognize and "expose" those custom fields with predefined options that you have carefully configured in the backend content model.
Custom field andarchiveFiltersDeep integration
So, specifically, how does AnQiCMS implementarchiveFiltersThe integration with custom fields? This is mainly due to two core mechanisms:
Content model field configuration:In the AnQiCMS backend, when you add custom fields to a content model, you can select different field types such as 'Single-line text', 'Number', 'Multi-line text', 'Single selection', 'Multiple selection', and 'Drop-down selection'. For those that need to be
archiveFiltersThe scenario of filtering by tags, the key is to chooseField type with preset optionsFor example, 'Single choice', 'Multiple choice' or 'Dropdown selection'.These field types allow you to define a series of "default values", such as the "apartment type" field with "one-bedroom", "two-bedroom", "three-bedroom", and so on.archiveFiltersThe basis for generating filtering conditions with tags.archiveFiltersDynamic parsing of tags:When you use it in the templatearchiveFiltersLabel it and specifymoduleIdfor examplemoduleId="1"It represents an article model, it will query all custom fields configured with preset options under the model. For each such custom field,archiveFiltersit will parse out itsParameter Name(Name, which is the Chinese display name of the field),Parameter Field Name(FieldNamewhich is the field name stored in the database, used for URL parameters) and all of the field'soptional values(ItemsThese optional values includeFilter value(Label)、Filter value link(Linkwhich will generate a URL with the corresponding filter parameters when clicked on"),Selected status(IsCurrent)
Through this mechanism,archiveFiltersIt can dynamically build a user-friendly filtering interface. When the user clicks on a filtering option (such as "Type: Three-bedroom"), the corresponding query parameters will be automatically added to the page URL (for example,?huxing=三居室)。Then, the page onarchiveListThe label (used to display document lists) will read these custom field query parameters from the URLs and filter the content that meets the conditions from the database accordingly. Therefore,archiveFiltersIs the generator of the filter UI, whilearchiveListIt is the actual filter executor, working together with the former to achieve flexible filtering of custom fields.
Practice session: How to build custom filters in templates
Imagine we have a content model called "Real Estate Information" that includes a field namedhuxing(Floor plan) custom field, type is 'dropdown selection', the default value is set to '1 bedroom', '2 bedrooms', '3 bedrooms'.
We can use it like this in the template.archiveFiltersBuild the filtering interface:
{# 假设moduleId="3"是房产信息的内容模型ID #}
<div class="property-filters">
<h3>房产筛选</h3>
{% archiveFilters filters with moduleId="3" allText="不限" %}
{% for item in filters %}
<div class="filter-group">
<span class="filter-name">{{ item.Name }}:</span>
<ul class="filter-options">
{% for val in item.Items %}
<li class="{% if val.IsCurrent %}active{% endif %}">
<a href="{{ val.Link }}">{{ val.Label }}</a>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
{% endarchiveFilters %}
</div>
{# 接下来是结合筛选结果展示房产列表的archiveList标签 #}
<div class="property-list">
{% archiveList archives with moduleId="3" type="page" limit="10" %}
{% for property in archives %}
<div class="property-item">
<h4><a href="{{ property.Link }}">{{ property.Title }}</a></h4>
<p>户型:{% archiveDetail with name="huxing" id=property.Id %}</p>
{# 其他房产信息字段展示 #}
</div>
{% empty %}
<p>暂无符合条件的房产信息。</p>
{% endfor %}
{% endarchiveList %}
{# 分页导航 #}
{% pagination pages with show="5" %}
{# ... 分页链接的渲染代码 ... #}
{% endpagination %}
</div>
In this example,archiveFiltersWill findhuxingThis custom field, and generate 'One-bedroom', 'Two-bedroom', 'Three-bedroom' and other filter links. When the user clicks on these links, the page URL will be changed,archiveListThe tag will automatically be based on the URL parametershuxingto filter and display the corresponding real estate information.
Core strengths and operating value
archiveFiltersSupport for custom fields through labels has brought significant value to website operations:
- Improve user experience:Visitors can quickly locate the desired content according to their personal preferences, using customized filtering conditions, and avoid information overload.
- Enhance SEO effects:URLs with filtering parameters can be indexed by search engines, which helps in indexing the website content more finely and improves the ranking opportunities for long-tail keywords.
- Achieve fine-grained content marketing:Operators can classify and recommend content based on custom fields, and even combine data analysis to optimize filtering conditions to meet the deep needs of target users.
- Simplify development and maintenance: Template developers do not need to write complex filtering logic for each custom field, the AnQiCMS tag system automatically handles most of the work, improving development efficiency.
Summary
There is no doubt that AnQiCMS supportsarchiveFiltersis a tagfiltering user-defined content model fieldsIt's.It intelligently identifies custom fields configured in the content model and converts them into a user-friendly filtering interface.This design not only showcases the high customizability of AnQiCMS, but also provides strong content organization and presentation capabilities for website operations, helping us better serve users, optimize SEO, and ultimately achieve operational goals.
Frequently Asked Questions (FAQ)
Q: Can all types of custom fields be
archiveFiltersautomatically identified and used for filtering?A: Not all.archiveFiltersTags are mainly aimed at custom fields configured in the content model as 'single choice', 'multiple choice', or 'drop-down selection' with preset options. For fields such as 'single-line text', 'multi-line text', or 'numbers', they are usually not suitable for filtering in list form and are more commonly used for full-text search or specific range queries, which may require combiningarchiveListlabel'sqParameters or a more complex custom search logic can be implemented.Q: I have set up a custom field in the background, but
archiveFiltersWhy didn't the tag generate a filter condition?A: This may be because your custom field type does not belong to the