AnQiCMS as a powerful and highly flexible content management system provides many conveniences for operators in terms of content display and management. Among them,archiveFiltersLabels are the key tools for implementing dynamic content filtering. Today, let's delve into a problem that operators often care about: archiveFiltersCan the tag limit some parameters to only be available under specific categories?
Deep analysisarchiveFiltersThe operation mechanism of the tag
First, let's understandarchiveFiltersThe core role of the tag. As we can see from the documentation,archiveFiltersTags are designed to build dynamic document parameter filtering conditions. When your website content, such as real estate information, product lists, and so on, needs users to filter combinations based on various properties (such as house type, area, color, size, etc.),archiveFiltersLabels can be very useful. They can automatically generate filter options for the front end based on the document parameters you set, greatly enhancing user experience and content discoverability.
Basic usage is as follows:{% archiveFilters filters with moduleId="1" allText="默认" %}...{% endarchiveFilters %}. Here,moduleIdThe parameter clearly specifies which 'content model' it will target to obtain filtering parameters. For example,moduleId="1"Indicates the filtering parameters for the article model.
Core clarification: The relationship between Module and Category
To answer the question of whether certain parameters can be limited to specific categories, we need to clarify the relationship between the 'Content Model' (Module) and 'Document Category' (Category) in AnQiCMS.
In the design philosophy of AnQiCMS, the custom content parameters (i.e., those used forarchiveFiltersfiltering the "parameters") arebound at the content model (Module) levelThis means that when you add custom fields such as 'House Type', 'Color', 'Size', and so on to the 'Article Model' or 'Product Model' in the background, these fields will become potential properties of all documents under the content model.
And the 'Document Classification' is organized and subdivided under the 'Content Model'. A classification always belongs to a specific content model. Therefore, when you are using a classification page onarchiveFiltersWhen a label is used, it will default (or according to your specifiedmoduleIdparameter) to load the content model of the category it belongs toall defined filter parameters.
So, the direct answer is:archiveFiltersThe tag itself cannot pass its parameters (such as passingcategoryIdTo limit it to display only the filtering parameters专属 of a specific category. It always provides all filtering parameter options based on the associated "content model".
How to implement a 'look' category-specific filter?
AlthougharchiveFiltersTags are module-level in the underlying logic, but as a senior operation expert, we always have ways to present the effect of 'category exclusive filtering' on the front-end through flexible strategies. Here are several practical methods:
Template-level control:This is the most commonly used and flexible method.
- Use exclusive templates for different categories:AnQiCMS supports custom templates for each category. For example, you may have a "real estate category" using
house-list.htmltemplates, while a "news information" category usesnews-list.htmlTemplate. - Render selectively in the dedicated template
archiveFilters:In the 'Real Estate Classification'house-list.htmlTemplate, you can fully render all the filter parameters related to real estate. And in the 'News and Information'news-list.htmlIn the template, you can choose not to renderarchiveFiltersTags, or only render a small amount of general parameters that are meaningful for news articles (if any). - CSS/JavaScript dynamically hide:Even if all module-level parameters are rendered, you can selectively hide some unrelated filter options on a specific category page by writing CSS or JavaScript code, thereby achieving the effect of 'category exclusive' visually.This method is not very elegant, but it is very practical in some complex scenarios.
- Use exclusive templates for different categories:AnQiCMS supports custom templates for each category. For example, you may have a "real estate category" using
Refined design of the content model:
- If the content differences between your different "categories" are huge, and the required filtering dimensions do not overlap at all, then it may be necessary to consider assigning them from the very beginningDifferent content modelsFor example, real estate information should have an independent "real estate model", and product information should have an independent "product model". Different models have their own independent custom field sets, so that
archiveFiltersWhen calling different models, different filtering parameters will naturally appear. This method solves the problem from the perspective of system architecture, but requires good design in the content planning stage.
- If the content differences between your different "categories" are huge, and the required filtering dimensions do not overlap at all, then it may be necessary to consider assigning them from the very beginningDifferent content modelsFor example, real estate information should have an independent "real estate model", and product information should have an independent "product model". Different models have their own independent custom field sets, so that
Utilize
archiveListThe data filtering capability:- Even if
archiveFiltersLists all module-level parameters, and the final filtering effect is still determined byarchiveListthe tag to complete.archiveListWhen processing filter parameters, it will only match based on the actual documents data existing under the current category. This means that if a document in a "news category" has never set the "house area" parameter, then evenarchiveFiltersThe label displays the 'House Area' filter option, and when the user clicks it, only an empty result is obtained, indirectly indicating that this parameter is not suitable for this category.Although this method does not have a clear 'hide', it can still guide the user.
- Even if
Summary
Of Security CMSarchiveFiltersTags are a powerful tool that provides rich document parameter filtering functions based on content models. Although they cannot be used directly at the tag level to according tocategoryIdLimit the available parameters, but through clever template design, reasonable content model planning, and front-end presentation control, we can fully realize a filtering experience that meets specific classification needs, making website content management both efficient and flexible.
Frequently Asked Questions (FAQ)
Ask: If my website has two types of content, articles and products, and they both need different filtering parameters, how should I set them up? Answer:**Practice is to create different "content models" for "articles" and "products" (for example, the system default article model and product model).Then define exclusive custom fields under their respective models (such as articles have "author", "source", and products have "color", "size").Thus, when you call on the article list page
archiveFiltersIt will display relevant parameters based on the article model; when called on the product list page, it will display product parameters based on the product model, thus naturally achieving isolation.Ask: Can I only display the filter parameters I want on a category page and hide other parameters that are not relevant to this category? Answer:Can be. You can set a dedicated category template for this specific category. In this category template, you can manually selectively render
archiveFiltersThe label outputs the filtered content, or use CSS styles (such asdisplay: none;) to hide unrelated filter options, thereby visually presenting only the filtering parameters related to the current category.Question:
archiveFiltersDoes the displayed parameter automatically filter out filter values without content? Answer:archiveFiltersThe tag itself lists all the parameters defined by the content model and their predefined optional values (if the parameter type is single-choice, multi-choice, etc.). As for whether there is actual document content under a specific filter value on the specific page, this is determined by the user after the filtering operation, byarchiveListTags combined with database queries to complete.archiveFiltersMainly responsible for presenting “Options available for filtering”, whilearchiveListResponsible for “executing the filter and displaying the results”.