As an experienced website operations expert, I am well aware of the flexibility and strength of AnQiCMS (AnQiCMS) in content management. In daily operations, we often need to precisely control the way content is displayed,archiveFiltersThe tag is one of the key tools to achieve this goal, it can generate dynamic filtering conditions based on the various parameters of the document.However, understanding the mechanism behind the automatic generation of filter links through template tags, and learning to manually simulate these filtering effects, will bring greater flexibility and control to our content operation.
Today, let's delve into how to manually simulate by modifying URL parametersarchiveFiltersThe filtering effect of tags makes the content display of Anqi CMS more at ease.
archiveFiltersLabel: The幕后推手 behind dynamic page filtering
First, let's take a look backarchiveFiltersThe role of labels. In Anqi CMS, when you deploy them in templates,archiveFiltersThe tag, it will automatically render a set of clickable filter links based on the custom fields defined in your content model (such as "house typeThese links' click effects are to dynamically filter the document list.
These are byarchiveFiltersGenerated links, which embody a very important logic: they are actually implemented by adding specific query parameters to the page URL to filter. For example, if you have a content model that contains a namedpropertyType(House type) Custom field, and this field has options such as "Residential", "Commercial" and so on, thenarchiveFiltersIt may generate a similaryourdomain.com/list?propertyType=住宅link.
The key point here is the URL in?propertyType=住宅This is the filtered 'command'.propertyTypeIt is the 'Field Name' of your custom field, and住宅This is a specific filter value for this field. Understanding this, we can bypass itarchiveFiltersAutomatic generation of tags, directly constructing a URL with filtering effects.
Parse URL parameters: Manually build the filtering logic
Need to simulate manuallyarchiveFiltersThe filtering effect, the core lies in correctly identifying and constructing the query parameters in the URL. This usually involves two key pieces of information:
Custom field's 'call field' (FieldName):This is the English name you set for the custom parameter in the AnQi CMS background content model. For example, if you add a custom field named "House Type" in the article model, its field name is set to
propertyTypeThen you need to use in the URLpropertyTypeas the parameter name.The expected filtering value (Value):This is the specific content you want to filter out. For example,
propertyTypeField, you may want to filter out documents with the value 'residential'.
Once you have mastered these two pieces of information, you can build a URL with filtering conditions like this:
你的文档列表页URL?调用字段名=筛选值
For example, suppose your document list page isyourdomain.com/housing/listand you have a custom fieldpropertyTypeand you want to filter documents of the "residential" type, then you can manually construct such a URL:yourdomain.com/housing/list?propertyType=住宅
If you want to filter based on multiple conditions at the same time, such as not only a "residential" property but also a "three-bedroom two-living-room" layout (assuming the field for the layout isapartmentLayout), you can use&Symbol concatenates multiple parameters:yourdomain.com/housing/list?propertyType=住宅&apartmentLayout=三室两厅
When the user accesses the URL with these parameters, in the front-end page ofarchiveListtag (if it has one, it is used totypeis set topageThese filters will automatically recognize and apply these conditions, thus displaying a list of content that meets the requirements, which is completely consistent with clicking the filter button througharchiveFiltersthe tag filter button effect is consistent.
Practice Steps: From Custom Fields to Filterable Links
Now, let's break down how to practice this skill in detail:
Understand your content model and custom fields.Log in to the AnQi CMS backend and navigate to "Content Management" under "Content Model".Select the model you want to filter (for example, "article model" or a custom model).Here, you will see all the custom fields defined under this model.Please note each custom field's "fieldName", which is the name you will use in URL parameters.At the same time, if you are filtering single-choice, multiple-choice, or drop-down selection fields, all available options will be listed in the 'default value'.
Confirm the filter conditions you want to apply.Choose one or more custom fields based on your operational needs, and determine the specific values you want to filter. For example, you may want to filter out
colorField is红色andsizeField isLof the product.Build URL query parameters.Combine the "Call field name" and "Filter value" determined in the previous step into
FieldName=Valueformat. If there are multiple conditions, use&Connect them.- Single condition example:
?color=红色 - Multiple condition example:
?color=红色&size=L
- Single condition example:
Attach the parameters to your document list page URL.Find the base URL for your document list page (for example,
yourdomain.com/products)。Then append the query parameters you have constructed to it. Complete URL example:yourdomain.com/products?color=红色&size=LTest and verify.Access the URL you manually built in the browser.Check if the document list displayed on the page is correctly applying the filters you have set.
archiveFiltersThe filtering effect!
The value and application scenarios of this method.
Master the ability to manually simulate through URL parametersarchiveFiltersThe ability to filter will bring many conveniences to the operation of your Anqi CMS website:
- Flexible external links:You can directly link to the content list under specific filter conditions from any page of the website (even external websites), without the need for users to click through filters on the page step by step, which is very useful for marketing promotion and thematic guidance.
- Advanced SEO Strategy:For certain filtering combinations with potential traffic, you can create SEO-friendly entry pages and allow search engines to directly crawl this pre-filtered content, improving the ranking of long-tail keywords.Of course, this requires the cooperation of AnQiCMS's pseudo-static and Canonical URL features to avoid duplicate content issues.
- Debugging and Troubleshooting:When
archiveFiltersWhen the label display is abnormal or the filtering logic is incorrect, manually constructing URL parameters can help you quickly locate the problem, and verify whether the backend data and template rendering meet expectations. - Personalized user experience:Based on the user's historical behavior or specific needs, dynamically generate links containing preset filtering conditions to provide more personalized content recommendations.
Some important considerations
When applying this technology, there are several points to note:
- The parameter name matches the value:Ensure you use
调用字段名defined in the backend content model:FieldNamecompletely consistent, and筛选值Also matches the actual value of the field (especially for radio, checkbox, dropdown types, etc.). Case sensitivity may also be a factor. - URL encoding: If your filter value contains Chinese characters, spaces, or other special characters, it is recommended to perform URL encoding (for example,
红色The encoded result may be%E7%BA%A2%E8%89%B2)。Although modern browsers and AnQiCMS usually handle it automatically, it is a good habit for compatibility and rigor to manually encode complex values. - Static rules:Manually added URL query parameters (
?key=value) Usually appended after the base URL generated by the static rule, it will not destroy the existing pseudo-static structure. However, it is always recommended to thoroughly verify in a test environment. - SEO Impact: Too many and disordered URL parameters may cause search engines to consider a large number of duplicate contents. If you need to include pages with parameters in SEO consideration, you must cooperate with the AnQiCMS Canonical URL setting or by
robots.txtManage the grab reasonably.
By understanding and utilizing URL parameters, you will be able to control the content display of AnQi CMS more deeply, unlocking more possibilities for refined operation.This is not only a technical exploration, but also a powerful boost to website user experience and content marketing efficiency.
Frequently Asked Questions (FAQ)
1. Why don't the manually constructed URL parameters take effect, and the content displayed on the page is not filtered?This usually has several reasons:
- The field name does not match:Ensure the parameter name you use in your URL (for example
propertyType) matches the custom field defined in the backend content model’s “