How to implement custom attribute display and filtering for document parameter tag `archiveParams` and filter tag `archiveFilters`?

Calendar 👁️ 68

In Anqi CMS, displaying and filtering custom content attributes are the core of implementing flexible and personalized website functions. With the help of template tags in thearchiveParamsandarchiveFiltersWe can easily display custom content fields on the front end and provide users with powerful features for filtering content based on these fields, thus greatly enhancing the user experience and discoverability of the website.

archiveParamsLabel: Flexible display of custom properties

In AnQi CMS, we first define unique fields for different types of content (such as articles, products) through the "Content Model" feature.In addition to system built-in fields such as title, content, and publish time, we can also add custom fields like 'author', 'source', 'price', 'size', etc.These custom fields are the foundation for personalizing website content.

When we need to display these custom properties on a document detail page (such as a product introduction or a professional article),archiveParamsThe tag comes into play. Its main function is to obtain all the custom parameters associated with the current document or a specified document.

UsearchiveParamsVery intuitive. You can place it in the template of the document detail page, and it will automatically obtain the custom parameters of the current page document.If you need to get the parameters for a specific ID document, you can also throughidparameter.

archiveParamsThere are two common ways to access the custom parameters returned by the tag:

  1. As a fixed sorting array (default behavior,sorted=true):When we want to display all custom fields in order, this method is very suitable. The tag will return a list containing the names of each custom field (Name) and value (ValueThe object array. We can iterate through and display all custom parameters in the template, for example:{% for item in params %}Such a loop structure, iterate and display all custom parameters, for example:

    {% archiveParams params %}
    <div>
        {% for item in params %}
        <p>{{item.Name}}:{{item.Value}}</p>
        {% endfor %}
    </div>
    {% endarchiveParams %}
    

    This is especially convenient when displaying all specifications on the product details page, no need to preset field names, the system will automatically list all parameters added in the background.

  2. As an unordered Map object (sorted=false):If we only want to accurately obtain the value of a specific custom field and know its field name (for example, the "call field" of the background custom field is set toauthorWe can convertsortedthe parameter tofalseThus,archiveParamsIt will return a Map, we can directly access it through.By adding an operator and the name of the field being called to access its value, for example:

    {% archiveParams params with sorted=false %}
    <p>作者:{{params.author.Value}}</p>
    {% endarchiveParams %}
    

    This method is suitable for scenarios where a single, known custom field needs to be referenced in a template.

Combined with document details tagarchiveDetailWe can even directly call the name of the custom field to get its value, for example{% archiveDetail with name="author" %}This provides great flexibility for template developers, allowing them to choose the most suitable display method based on actual needs.

archiveFiltersLabel: Drives the dynamic filtering of the user experience

When we have a large amount of content and we want users to be able to narrow down the search range based on these custom properties,archiveFiltersTags are particularly important. They are mainly used to generate filtering links based on custom attributes on document list pages or category pages.Imagine a real estate website where users may need to filter listings by custom attributes such as 'house type', 'price range', 'area', etc.archiveFiltersIt is born for this.

this tag needs to be with,archiveList(used to display document lists) andpagination(Used for pagination) Tag used in conjunction to build a functional filter and list display page.

archiveFiltersThe tag will return an array containing multiple groups of filtering conditions, each corresponding to a custom attribute. Each filtering condition group contains a series of selectable values, each with a URL link for executing the filter, and aIsCurrentStatus, indicates whether the current filter value is selected.

UsearchiveFiltersThe basic process is as follows:

  1. Define filter properties:First, in the Anqi CMS backend's "Content Model", make sure you have defined custom fields that can be used for filtering in your content model (for example:户型/面积)
  2. Use in the template:In the document list page template, usearchiveFilterstags to obtain the filtering condition data. It is usually assigned to a variable, for examplefilters:
    
    {% archiveFilters filters with moduleId="1" allText="不限" %}
        {% for item in filters %}
        <div class="filter-group">
            <span>{{item.Name}}:</span> {# 筛选属性的名称,如“户型” #}
            <ul>
                {% 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 %}
    
    HeremoduleIdThe parameter is very important, it tells the label which custom filter attribute of the content model should be retrieved.allTextIt is used to set the display text for the 'unlimited' or 'all' options.

when the user clicks{{val.Link}}The page will reload when generating the filter link andarchiveListThe tags will display content that matches the filter parameters carried in the URL.IsCurrentThe attribute helps us add styles (such as highlighting) to the currently selected filter condition, enhancing user experience.

ByarchiveParamsandarchiveFiltersThese tags, Anqi CMS provides high flexibility for website operators, whether it is to display the rich details of a single content or to provide users with multi-dimensional content filtering, it can be easily realized, making content management and user interaction more efficient and personalized.


Frequently Asked Questions (FAQ)

Q1: How should I define custom fields so thatarchiveParamsandarchiveFiltersthey can be recognized and used?

A1: You need to find the "Content Model" feature under the "Content Management" module in the Anqi CMS backend.Select the model you want to add a custom field to (for example, 'Article Model' or 'Product Model'), then click Edit.Here, you can add new "custom fields", set the "parameter name" (for background display), "calling field" (for template call), "field type" and other options.Especially, if you want the field to be used for front-end filtering, make sure its data type and settings meet the filtering requirements.

Q2:archiveFiltersCan all types of document fields, including category IDs, tags, etc., be filtered?

A2:archiveFiltersTags are primarily designed to filter the content model you are inCustom attribute fields. For filtering system-built-in fields like category ID (categoryId), recommended attributes(flag), you should directly inarchiveListTag through the corresponding parameters (such ascategoryId="1"/flag="c") to set.archiveFiltersThe advantage lies in its ability to dynamically generate filter options and links for your custom fields, allowing users to filter these specific custom properties through interface interaction.

Q3: If my custom field has no value,archiveParamsHow will it be handled?archiveFiltershow will it behave?

A3: If a custom field is not filled in the document:

  • archiveParamsthe field will beValueMay be an empty string ornilYou can use the template toifdetermine whether to display. If it passessorted=falsedirect access,params.yourFieldName.Valuewill also be an empty value.
  • archiveFiltersIt is usually not recommended to display custom fields without values as filter criteria. If all documents for a custom field are not filled in, or if optional values are not set, thenarchiveFiltersLabels may not generate a filter group for this field. If set,allTextThe parameter will display the option of "All" or "Unlimited", but if there are no other specific filter values, the filtering of this field may not have any actual significance.

Related articles

How to implement navigation display between content for previous/next document tags `prevArchive`/`nextArchive`?

In website operation, providing readers with a smooth reading experience is the key to enhancing user satisfaction and website value.After a user finishes reading an exciting article or product introduction, if they can conveniently see related content such as 'Previous' or 'Next', it will undoubtedly greatly increase their time spent on the website, forming a more natural browsing path, which is very beneficial for SEO optimization and content dissemination.AnQi CMS, as a powerful content management system, fully understands this need

2025-11-07

How to retrieve and display the full content of a single document using the `archiveDetail` detail tag?

In AnQi CMS, displaying the full content of a single document is the foundation of website operation.Whether you are publishing a news article, a product detail, or a service introduction, the core lies in how to present the data entered in the background efficiently and accurately to the user.This is where the `archiveDetail` tag and its related mechanism come into play.

2025-11-07

How to filter and paginate articles or products by conditions in the document list label `archiveList`?

In Anqi CMS, when we want to display a series of articles, products, or other content on the website page, the `archiveList` tag is an indispensable powerful tool.It can not only help us flexibly extract and display various types of content, but also perform precise filtering according to multiple conditions, and elegantly implement the pagination display of content, thereby greatly enhancing the user's browsing experience and the information organization efficiency of the website.

2025-11-07

How to manage and display static page content for single-page list tags `pageList` and single-page detail tags `pageDetail`?

In website operation, static pages play an indispensable role, they usually carry fixed and not frequently updated core content such as "About Us", "Contact Information", "Privacy Policy", and "Service Introduction".AnQi CMS provides two powerful tools for the management and display of these pages: the single-page list tag `pageList` and the single-page detail tag `pageDetail`.These two work together to allow you to easily handle the static content of the website, whether it's building navigation, displaying service lists, or presenting detailed corporate introductions, you can do it with ease.###

2025-11-07

How to implement the labeling display of document Tag list label `tagList`, detail label `tagDetail`, and document list label `tagDataList`?

In website operation, efficient content management and flexible content display are the key to improving user experience and search engine performance.AnQiCMS (AnQiCMS) is well-versed in this, providing powerful tag features to help us easily implement the labeling and display management of content.By skillfully utilizing `tagList`, `tagDetail`, and `tagDataList` as these core tags, we can give wings to the website content, making information organization more scientific, user search more convenient, and also lay a solid foundation for SEO optimization.Core

2025-11-07

How to get and display the comments made by users on the content for the comment list label `commentList`?

In today's digital world, websites are not just platforms for displaying information, but also spaces for user interaction and communication.When users can express their opinions and ask questions about the content, the vitality of the website will be greatly enhanced.Anqi CMS knows this and therefore provides a powerful and flexible comment management feature, where the 'comment list tag `commentList`' is the key bridge connecting content and user feedback. Imagine that you have published an engaging article or an innovative product, and users can't wait to share their thoughts after reading it.As a website operator

2025-11-07

How to dynamically generate and display the user's guestbook form with the label `guestbook`?

In website operation, visitor comments and interaction are important for building trust, obtaining feedback, and promoting business development.AnQiCMS (AnQiCMS) understands this need and provides a flexible and powerful message form feature, allowing you to easily generate and display user message forms on your website.This is mainly achieved through its built-in `guestbook` template tag, which not only allows you to customize form fields but also ensures the safety and smooth submission of the form.### Understand `guestbook`

2025-11-07

How to display the link list of cooperative website links with the tag `linkList`?

In website operation, friendship links (also known as cooperative website links) play an important role.They not only bring additional traffic to the website, but also help to improve search engine optimization (SEO) performance, enhance the authority and user trust of the website.In Anqi CMS, managing and displaying these links becomes very convenient, mainly due to its powerful template tag system, especially the `linkList` tag.### Flexibly display cooperative websites: `linkList` tag usage and basic principles `linkList`

2025-11-07