How to use the `archiveParams` tag to retrieve and display the content of the custom parameter fields of the document?

Calendar 👁️ 72

In the operation of daily websites, we often encounter such needs: standardized content fields can no longer meet the diversified information display.For example, a product detail page may need to display unique attributes such as "model", "material", "warranty period", etc., while an ordinary article may need to additionally note "source of the article", "estimated reading time", etc.archiveParamsTags, allowing you to easily retrieve and display these customized information exclusive to the documents.

This article will delve into how to utilizearchiveParamsLabel, display the custom parameter content of the document on the website front-end, making your content display more rich and personalized.

Configure custom parameters: Inject vitality into your content model.

Before discussing how to display these parameters, we first need to understand how they are created and added.The custom parameters of AnQi CMS are closely related to the 'Content Model'.Each content model can have its own unique set of custom fields, which will serve as additional information for all documents under the model.

To start the setup, you need to enter the Anqi CMS admin interface, find the "Content ManagementThe system provides the 'Article Model' and 'Product Model' by default, and you can also create new content models according to your business needs.

Select a model you wish to add custom parameters, click the edit button.On the model editing page, you will see a "Content Model Custom Field" area.

  • Parameter NameThis is the field name you see and understand in the background management interface, such as "Product Model", "Article Author".
  • Field invocationThis is the unique identifier used to call the parameter in the template, it is usually recommended to use letters. For example, if the parameter name is "Product Model", the calling field can bemodelNumberIn the template, you will get the value through this field name.
  • Field type: AnQi CMS supports various field types such as single-line text, numbers, multi-line text, single selection, multiple selection, dropdown selection, etc., and you can choose according to the actual information type.
  • Mandatory?: Determines whether the user must fill in this field when publishing a document.
  • Default value: Sets a default value for the field, which will be used if the user does not fill in the field.

After completing the addition and saving of custom fields, when you go to publish or edit the documents under the content model again, in the "Other Parameters" section of the document editing page, you will see these newly added custom fields, and you can fill in exclusive content for each document.

archiveParamsLabel: Display custom data accurately in the template

Now, the core task is here: How can these custom parameters, carefully configured and filled in the background, be presented on your website page? The answer is to use the Anqi CMS providedarchiveParams.

archiveParamsThe tag is mainly used to obtain all custom parameters of a specified document. You can choose to traverse and display all parameters in the form of an array in fixed order, or directly obtain the value of a specific parameter in the form of a key-value pair (Map).

1. Traverse all custom parameters (recommended: an array in fixed order)

On the document details page (or any page where you can obtain the document ID), if you want to display all the custom parameters of the current document, you can usearchiveParamsLabel it and let it return an array. By default,archiveParamslabel'ssortedthe parameter istruewhich means it will return an ordered list containing all the parameters.

Each list item is an object that containsName(Parameter name, that is, the Chinese name set in the background) andValue(Parameter value).

{# 假设我们正在一个文档详情页,它会自动获取当前文档的自定义参数 #}
<div class="custom-parameters">
    <h3>详细参数</h3>
    {% archiveParams params %} {# params 是您为获取到的参数定义的变量名 #}
        {% for item in params %}
            <p><strong>{{ item.Name }}:</strong>{{ item.Value }}</p>
        {% endfor %}
    {% endarchiveParams %}
</div>

By this code, your website will traverse and display all the custom parameters and their corresponding values of the current document, such as "Product Model: XYZ-2023", "Material: Stainless Steel", and so on, greatly enhancing the information content of the content.

2. Retrieve specific custom parameters (unordered key-value pairs or directly througharchiveDetail)

Sometimes, you may not need to iterate through all the parameters, but just want to retrieve and display a specific custom parameter, such as only displaying the "product model" or "article author". At this time, you can letarchiveParamsReturn an unordered key-value pair (Map), or use a more concise way toarchiveDetail.

Method one: usearchiveParamsReturn an unordered key-value pair

By settingsorted=false,archiveParamsThe label returns a key-value pair object, where the key is the field you set in the background, and the value is the object that containsNameandValuethe object.

{# 假设要获取调用字段为 'modelNumber' 和 'author' 的自定义参数 #}
<div class="specific-parameters">
    {% archiveParams customFields with sorted=false %}
        <p>产品型号:{{ customFields.modelNumber.Value }}</p>
        <p>文章作者:{{ customFields.author.Value }}</p>
    {% endarchiveParams %}
</div>

This method is suitable for cases where you need to retrieve multiple but not all custom parameters, throughcustomFields.调用字段.ValueYou can directly access it in this form.

Method two: access directlyarchiveDetailtag to obtain

For scenarios where only a single specific custom parameter is needed, AnQi CMS provides a more direct and concise method: usingarchiveDetailLabel. If you know the "calling field" of the custom parameter, you can use it directlyarchiveDetailto get its value, just like getting system-built-in fields such as document title, content, etc.

<div class="quick-access-parameters">
    <p>产品型号:{% archiveDetail with name="modelNumber" %}</p>
    <p>文章作者:{% archiveDetail with name="author" %}</p>
    {# 如果自定义字段是组图类型,例如调用字段为 'productImages' #}
    {% archiveDetail productImages with name="productImages" %}
        {% if productImages %}
            <div class="product-gallery">
                {% for imgUrl in productImages %}
                    <img src="{{ imgUrl }}" alt="产品图片">
                {% endfor %}
            </div>
        {% endif %}
    {% endarchiveDetail %}
</div>

This method is very suitable for scenarios where your page layout is fixed, only a few known custom parameters need to be displayed, and the code is more concise and readable.

3. Get custom parameters for a specified document.

This example defaults to retrieving the custom parameters of the current document. If you need to retrieve the custom parameters of *other* documents on the current page, you can specify the document ID throughidthe parameter.

{# 获取ID为123的文档的所有自定义参数 #}
{% archiveParams otherDocParams with id="123" %}
    {% for item in otherDocParams %}
        <p><strong>{{ item.Name }}:</strong>{{ item.Value }}</p>
    {% endfor %}
{% endarchiveParams %}

{# 获取ID为456的文档的某个特定自定义参数 'material' #}
<p>其他文档的材质:{% archiveDetail with name="material" id="456" %}</p>

In addition, for users managing multiple sites, if they need to call data from other sites, they can also add parameters in the tag to specify the site ID.siteIdto specify the site ID.

Make flexible use of custom parameters to enrich your website content

ByarchiveParamsandarchiveDetailLabel, you can fully utilize the custom parameter function of AnQi CMS.Whether it is to add detailed specifications to the product list, supplement additional information to the article, or display registration details on the event page, these custom parameters can help you build more expressive and business-demand-aligned content.They not only make your content more attractive, but also provide more possibilities for structured data in SEO optimization, allowing search engines to better understand and display your page.

MasteredarchiveParamsLabel, you have the key tool to achieve highly customized content in Anqi CMS. Dare to try and let your website content soar to new heights!


Frequently Asked Questions (FAQ)

Q1: Why did I add custom fields but they do not display in the template?

A1: The most common reason is that the 'called field' used in the template does not match the background settings, or you have usedarchiveParamsLabel but did not correctly traverse the returned structure. Please check the following points:

  1. Spell the field name: Confirm the template in thecustomFields.fieldName.Valueor{% archiveDetail with name="fieldName" %}offieldNameConsistent with the "call field" set in the background content model, including case sensitivity.
  2. sortedParameter impactIf you have used:archiveParamstag, sorted=true(Default) It returns an array, which needs to be{% for item in params %}{{ item.Name }}: {{ item.Value }}{% endfor %}traversed in this way. Andsorted=falseReturns a key-value pair, it can be used directly{{ params.fieldName.Value }}Access. Make sure you use the access method that matches the return type.

Related articles

How to dynamically generate and display SEO titles, keywords, and descriptions for `tdk` tags on different pages?

In website operation, the title (Title), keywords (Keywords), and description (Description), known as TDK, are indispensable core elements of search engine optimization (SEO).They not only directly affect the display of the website on the search engine results page (SERP), but also determine whether users click to enter your website.

2025-11-08

What global website information and contact details can the `system` tag and `contact` tag retrieve and display?

In the daily operation of AnQiCMS, the global information and contact information of the website are highly concerned by users and frequently change.How to efficiently and uniformly manage and display this information is an important standard for measuring the flexibility of a content management system.AnQiCMS provides an extremely convenient solution for calling website content and contact information through its unique template tag system, especially the core tags `system` and `contact`.

2025-11-08

How is the `bannerList` tag used to fetch and display the carousel of the website homepage or a specific group?

When building modern websites, the banner carousel is a commonly used element to enhance visual appeal and convey important information.They are usually located in prominent positions on websites, such as the top of the homepage, to display the latest activities, featured products, or important announcements.In AnQiCMS (AnQiCMS), managing and displaying these carousel images becomes very convenient, mainly due to its powerful template tag system, especially the `bannerList` tag.`bannerList`

2025-11-08

How to build a clear breadcrumb navigation through `breadcrumb` tags to enhance users' sense of positioning on the website?

In website operation, how to keep visitors from getting lost in the vast content while browsing, and maintain a clear sense of orientation, is a crucial issue.Imagine if a user delves into a page on a website and is unclear about where they came from or their level, they are likely to feel confused and even choose to leave.At this time, a well-designed and functional breadcrumb navigation can play a key role, it is like a 'road sign' in the digital world, providing users with a clear return path.AnQiCMS (AnQiCMS) is deeply skilled in content management and user experience

2025-11-08

How to customize the display template for articles, products, and single pages in AnQiCMS?

In AnQiCMS, customizing the display templates for articles, products, and single pages is a very flexible and powerful feature that allows you to create exclusive display styles for different types of content according to the unique needs of your website.By carefully designed templates, not only can the user experience be improved, but also the focus of the content can be better highlighted, achieving the unity of brand style.AnQiCMS uses a template engine syntax similar to Django, which means if you are familiar with this concise and intuitive syntax, you can quickly get started.

2025-11-08

How to display custom fields defined in the AnQiCMS content model on the front end?

AnQiCMS's flexible content model is one of its core advantages, allowing us to define unique fields for different types of content according to actual business needs, thereby freeing ourselves from the limitations of traditional CMS fixed content structure.When we create these custom fields, the next critical step is to display them elegantly on the website frontend.This article will introduce you in detail how to define custom fields in the AnQiCMS backend, as well as how to flexibly call and display this information in the frontend template, making your website content more personalized and practical.### One

2025-11-08

How does AnQiCMS implement the switch of multilingual content and correct display?

In order to meet the content operation needs of globalization, it is a key step to enable your website to support multi-language content switching and correct display, expanding the market and enhancing user experience.AnQiCMS (AnQiCMS) is a feature-rich content management system that provides an intuitive and powerful multilingual solution, helping you easily meet this challenge.Next, we will discuss in detail how to achieve this goal in AnQiCMS.

2025-11-08

How to dynamically display the 'recommended properties' (such as headlines, recommendations) of articles or products on a page?

When operating website content, we often need to make special recommendations for certain articles or products, such as 'headline', 'hot', or 'recommended', etc., in order to display them more prominently on the page and guide users' attention.AnQiCMS provides a very flexible "recommendation attribute" feature, allowing you to easily achieve this.Let's take a look together at how to set these properties in AnQiCMS and dynamically display them on your website.

2025-11-08