How to use the `archiveParams` tag to dynamically display the product specification parameter list on the product detail page?

Calendar 👁️ 53

In today's content is king era, an efficient and flexible content management system is crucial for a company's online operation.AnQiCMS (AnQiCMS) is a modern enterprise-level content management system developed based on the Go language, with its powerful content model and template tag system, providing endless possibilities for us to carry out refined content operations.Today, let's delve into a very practical scenario: how to cleverly utilize AnQiCMS'sarchiveParamsThe tag dynamically displays a rich and diverse list of product specifications on the product detail page, thereby enhancing user experience and content maintenance efficiency.

Why does the product detail page need a dynamic parameter list?

In the daily operation of the website, I believe you also have a deep understanding that product information, especially its specifications and parameters, is the key for users to understand the product and make purchasing decisions.However, products are often not immutable, model updates, parameter adjustments, and new product launches are the norm.If each parameter modification requires manual adjustment of the page code, it is not only inefficient but also prone to errors.

The advantage of the dynamic parameter list is that it can extract product specifications from fixed page content and manage them independently.When the product parameters change, we just need to simply modify the corresponding field value in the background, and the front-end page can be updated in real time without touching a single line of code.This has greatly improved operational efficiency, reduced maintenance costs, and can ensure that users always receive the latest and most accurate product information, thereby significantly optimizing the user experience.AnQiCMS's powerful flexible content model was born to meet such dynamic needs.

archiveParamsThe magic of tags: unlock the dynamic display of product parameters

One of the core functions of AnQiCMS is the "flexible content model", which allows us to customize the content structure according to business needs, for example, creating a "product" model and adding various custom fields. AndarchiveParamsThe label is the bridge of communication between our front-end template and these custom fields.

In short,archiveParamsTags are used to obtainSpecify the documentParameters set in the background, including those customized specifications for the product model that we have set.It can extract these structured data to be traversed and displayed by the front-end template.This means that regardless of how many specification parameters you define for a product, they can all be presented through this tag in the form of a list on the product detail page, achieving true dynamism.

This tag was added when the template tag was redesigned in AnQiCMS v2.1.1 version, it replaced the previous specific tag, providing a more unified and powerful content model data acquisition ability.

Backend configuration: Build your product parameter structure.

While usingarchiveParamsBefore the label, we first need to configure the required specifications for the "Product" content model in the AnQiCMS backend.

  1. Enter content model management:Log in to the AnQiCMS backend, navigate to the 'Content Management' menu, and select 'Content Model'.
  2. Select or create a product model:The system usually built-in "product model", you can click edit to add fields for it, or create a new content model as needed (such as "electronic products", "clothing" etc.), and set the "model table name" to an easily recognizable English lowercase string, such asproduct.
  3. Add custom field:This is the most critical step. Under the product model you choose, click the 'Add field' button in the 'Content model custom field' area.Here, you can define a field for each product specification:
    • Parameter name:This is displayed on the back end and called on the front enditem.NameChinese names such as 'color', 'size', 'material', 'weight', and others will be used.
    • Call field:This is a unique identifier composed of English lowercase letters, for examplecolor/size/material/weightThis field is used on the front endsorted=falseIt is very useful when calling the pattern directly, but for our dynamic list display, it serves asitem.FieldNameHidden inside the loop.
    • Field type:Choose the appropriate type based on the actual parameters. For example, "color" can be "single-line text" or "dropdown selection", "size" can be "single-line text", "material" can be "single-line text", "weight" can be "numeric".When selecting 'Dropdown Selection', you can preset multiple options in the 'Default Value' for the convenience of operation staff.
    • Mandatory?:Tick according to business requirements.
    • Default:If there is a common value, it can be set in advance.

After completing these configurations, when you publish a new product in the "Content Management", select the corresponding product category, and under the "Other Parameters" collapse box, you will see these customized specification parameter fields. The operations personnel only need to fill in or select the specific product parameter values here.

Front-end template实战:Dynamically display product specifications list

After all the background configurations are ready, now we can go to the product details page (usually the template file{模型table}/detail.html), througharchiveParamsLabel to dynamically display these parameters.

Assuming the name of your product model table isproductThen the template path of the product detail page may be/template/您的模板名称/product/detail.html.

The following is a clear template code example that iterates through all custom parameters of the product and displays them in a list format.

{# 首先,确保这是产品详情页,并且已经有一个名为archive的变量包含了当前产品的数据 #}

<div class="product-specs">
    <h2>产品规格参数</h2>
    <ul class="specs-list">
        {# 使用archiveParams标签获取当前产品的后台自定义参数。
           默认情况下,sorted=true,它会返回一个按后台定义顺序排列的数组对象,
           非常适合我们遍历展示。
        #}
        {% archiveParams params %}
            {# 遍历params数组,每一个item都代表一个自定义参数 #}
            {% for item in params %}
                {# 我们可以添加一个条件判断,只有当参数有值时才显示,避免显示空行 #}
                {% if item.Value %}
                <li>
                    <span class="spec-name">{{ item.Name }}:</span> {# item.Name是我们在后台设置的“参数名” #}
                    <span class="spec-value">{{ item.Value }}</span> {# item.Value是运营人员在后台填写的具体参数值 #}
                </li>
                {% endif %}
            {% endfor %}
        {% endarchiveParams %}
    </ul>
</div>

{# 结合使用archiveDetail标签获取产品标题、内容等固定信息 #}
<div class="product-description">
    <h1>{{ archive.Title }}</h1>
    <div class="main-content">
        {{ archive.Content|safe }} {# archive.Content通常包含富文本内容,需要|safe过滤器避免转义 #}
    </div>
</div>

In this code block:

  • First, we defined a containerdiv.product-specsInclude all product specifications.
  • {% archiveParams params %}The tag is responsible for extracting all custom parameters from the current product (archiveobject) and storing them in a variable namedparams. Due tosortedThe parameter is set to default.true,paramsIt will be an ordered array, the order of whose elements is consistent with the order of the custom fields you define in the background.
  • {% for item in params %}Loop through thisparamsarray. In each loop,itemthe variable represents an independent custom parameter.
  • item.NameIt will output the parameter name you set in the background (for example, "color"), whereasitem.Valueit will output the specific value of the parameter (for example, "blue").
  • {% if item.Value %}This condition judgment is very practical, it can ensure that the parameter value is displayed on the page only when it is not empty, avoiding the embarrassing situation that there is no content after "Color: ", making the page more tidy.

Optimize user experience and content presentation

It's not enough to just dynamically display, we also need to consider how to better serve these information to users:

  • Style beautification:With.product-specs/

Related articles

How to loop through and display the `Name` and `Value` of custom parameters using the `archiveParams` tag in AnQiCMS templates?

In the flexible world of AnQiCMS, the custom parameters (Content Model) provide website operators with great freedom, allowing us to break through the limitations of traditional titles, content, and summaries, and add personalized data fields for different types of documents (such as articles, products, cases, etc.). For example, a product detail page may need to display information such as 'product model', 'color options', 'material', etc., while a technical article may require fields such as 'author', 'publication date', 'references', etc.

2025-11-06

In the `archiveParams` tag, what scenarios are `sorted=true` and `sorted=false` applicable to?

As an experienced website operation expert, I know that how to flexibly use template tags to display content in such an efficient content management system as AnQiCMS is the key to operation success.Today, let's delve into how the `archiveParams` tag's `sorted=true` and `sorted=false` parameters can have an effect in specific scenarios.Anqi CMS, with its concise and efficient architecture, provides great convenience for content creators and operators.

2025-11-06

In AnQiCMS, how does the `sorted` parameter of the `archiveParams` tag control the output order of custom parameters?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides great freedom in content display.Among them, the custom parameter function allows website operators to add unique attributes to content models such as articles, products, etc. according to their actual business needs, such as product specifications, author information, source channels, etc.How to elegantly display these custom parameters in the front-end template, especially the clever use of the core parameter `sorted`, is indispensable.

2025-11-06

How is the `archiveParams` tag's `id` parameter used to retrieve custom fields of a specific document?

As an experienced website operation expert, I am happy to give you a detailed explanation of how the `archiveParams` tag's `id` parameter is used to obtain custom fields of specific documents in AnQi CMS.The AnQi CMS, with its flexible content model and powerful template tag system, provides great convenience for content operations.Grasp the essence of these tags, which can make your website content display more personalized and greatly increase operational efficiency.

2025-11-06

How to call the `archiveParams` tag individually in AnQiCMS template to get custom document parameters with a specific name?

In the rich feature treasure trove of AnQiCMS, the content model and custom document parameters are undoubtedly the foundation of its flexibility and powerful extensibility.As an expert in website operations, I am well aware of how to efficiently and accurately call these custom parameters in templates, which is crucial for achieving personalized content display and optimizing operational efficiency.Today, let's delve deeply into a powerful and often overlooked technique in the AnQiCMS template: how to call the `archiveParams` tag individually to obtain custom document parameters with a specific name.Introduction

2025-11-06

How to implement cross-site calls for the `siteId` parameter of the `archiveParams` tag in the AnQiCMS multi-site environment?

## Mastering AnQi CMS Multi-Site: Cross-Site Call Practice of `archiveParams` Tag SiteId Parameter As an experienced website operations expert, I fully understand that efficient content management and flexible content scheduling are the keys to business success in increasingly complex network environments.AnQiCMS (AnQiCMS) provides powerful tools for operators with its excellent multi-site management capabilities.Today, let's delve into a very practical feature in a multi-site environment

2025-11-06

The `archiveParams` tag returns custom parameters, is the data structure a fixed array or a variable Map?

Hello, all website operators and AnQi CMS enthusiasts! Today, we will delve into a practical and flexible tag in the Anqi CMS template development——`archiveParams`.Many times, when using custom parameters, there is a question: What is the data structure of the custom parameters returned by the `archiveParams` tag, whether it is a fixed array or a variable Map?In order to better utilize the strong content model customization capabilities of Anqi CMS, it is crucial to understand this point.This article will explain in detail

2025-11-06

How to judge whether a custom parameter exists and display in AnQiCMS via the `archiveParams` tag?

In the powerful content management system of AnQi CMS, custom parameters (also known as content model custom fields) are an important manifestation of its flexibility.It allows operators to add personalized data to content models such as articles, products, etc. according to specific business needs.But in the front-end template, we often need to determine whether a custom parameter exists or has been assigned a valid value before deciding whether to display it.This is when the `archiveParams` tag becomes an indispensable tool.##

2025-11-06