How does the `archiveParams` tag display custom field data of the document on the frontend page?

Calendar 👁️ 66

In AnQi CMS, the flexibility of content is one of our core advantages in website operation and content management.In addition to standardized fields such as titles and main content, we often need to add specific custom information for different types of content, such as a product's 'brand', 'model', 'origin', or an article's 'author', 'source', etc.These custom fields greatly enrich the dimensions of content display, but how to accurately and flexibly present these meticulously entered background data on the front-end page is an important consideration during template development.

This provides by AnQi CMSarchiveParamsThe tag comes in handy. It is specifically used to retrieve and display the custom field data set in the background of documents (articles, products, and other content models), making your website content display more personalized and practical.

Understand the custom field witharchiveParamsbridging role

In the Anqi CMS backend, we can define a series of unique custom fields for different content types (such as the 'Article' model or the 'Product' model).When you add or edit a document, these custom fields will appear as "other parameters" on the editing interface for you to fill in additional information.

archiveParamsTags act as an intelligent bridge, capable of understanding the background parameters you define for the document and securely extracting them for use in front-end templates. Whether you want to list all parameters or focus on a specific one,archiveParamsCan help you easily achieve it.

archiveParamsBasic usage of tags

archiveParamsThe basic structure of the label is.{% archiveParams 变量名称 with 参数... %}{% endarchiveParams %}. We usually use it on the document detail page (such as article detail page or product detail page) because it defaults to retrieving the custom parameters of the current page document.

It supports several key parameters to control the way data is retrieved:

  • idThis parameter is used to specify the custom parameter for the document to be retrieved. It can usually be omitted when used on the document detail page.idIt will automatically retrieve the ID of the current document. But if you want to get the parameters of other documents, you can specify them explicitly byid="文档ID".
  • sortedThis is a very practical parameter, which determines the structure of the data you get.
    • Whensorted=true(This is also the default value) when,archiveParamsIt will return an array of objects arranged according to the background settings. Each element of this array is a containingName(field name, that is, the Chinese name displayed in the background) andValue(The field value, i.e., the specific data you enter) object.
    • Whensorted=falseIt returns an unordered map object when it happens. In this mode, you can directly access the data through the "field name called" (the English name defined in the content model), for exampleparams.your_field_name.Value.
  • siteIdIf you use the multi-site management function of Anq CMS and need to call data from other sites, you cansiteIdspecify it. Generally, we do not need to fill it in.

Two main display methods

MasteredarchiveParamsBy setting the parameters, we can choose different ways to display custom fields according to our needs.

1. Traverse all custom fields (suitable forsorted=trueWhen you do not know the specific field names, or when you are not sure about the custom fields of a document, or when you want to display all defined parameters uniformly, use the default one.

When you are not sure about the specific field names, or when you do not know the custom fields of a document, or when you want to show all defined parameters uniformly, use the default one.sorted=truePattern (or not specifiedsortedparameters), byforLoop traversal is a very convenient method.

Assuming you define custom fields such as "Brand", "Model", "Color", etc. in the background for products, you can display them like this in the product detail page template:

<div class="product-params">
    <h4>产品参数</h4>
    {% archiveParams params %}
        {% for item in params %}
        <p>
            <span>{{ item.Name }}:</span>
            <span>{{ item.Value }}</span>
        </p>
        {% endfor %}
    {% endarchiveParams %}
</div>

In this code block,paramsis an array that contains all custom fields. Each loop,item.Namewill display Chinese names such as "Brand", "Model", and so on,item.ValueIt will display the specific content you fill in the background, such as 'AnQi Technology', 'AQ-CMS-001', 'black', etc.This method is very suitable for dynamically listing all relevant information in areas such as 'Product Parameters' or 'Article Properties'.

2. Directly access specific custom fields (suitable forsorted=falseorarchiveDetailtags)

If you know the name of the 'display field' for a custom field (for example, you define a field to store the article author, whose 'display field' isauthor),and if you want to display only this field, accessing it directly will be more concise and efficient.

Method one: usearchiveParamswithsorted=falsetosortedthe parameter tofalseCan let you directly access values by calling the field name in a way similar to a dictionary (map):

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

HereauthorandpublisherIt is the 'callback field' name set for these custom fields in the content model.

Method two: througharchiveDetailDirectly obtain the tagThis is the most commonly used and simplest way on the document detail page. Anqi CMS provides a more direct approach, you do not need to usearchiveParamsthe loop structure of tags, you can directly go througharchiveDetailLabel to get the value of a single custom field.

For example, on the article detail page, if you have a custom field called "call field" isauthorYou can use it directly:

<p>作者:<span>{% archiveDetail with name="author" %}</span></p>

Even if the current template context already includes the document object (usually on a document detail page, there will be a name calledarchiveThe global variable), you can also access the custom field directly via dot notation:

<p>作者:<span>{{ archive.author }}</span></p>
<p>产品型号:<span>{{ archive.product_model }}</span></p>

This method is particularly suitable for those custom fields that you use frequently and have fixed names, making template code clearer and more readable.

Considerations and tips in practice

  • Field naming and invocation:When defining custom fields in the background, it is recommended to use concise, meaningful English lowercase letters or camel case naming for 'invoked fields', so that they can be easily called in templates (for exampleproduct_modelor `product`

Related articles

How to use the `archiveList` tag's `type="related"` feature to display related article recommendations?

On your website, when visitors finish reading an article, if they can see related content in time, it not only can significantly improve the user experience, reduce the bounce rate, but also can effectively increase the page views and stay time on the website.AnQi CMS provides a very convenient tag: `archiveList`,配合其`type="related"` attribute, it can easily realize this function.###

2025-11-08

How to implement the previous/next document function using `prevArchive` and `nextArchive` tags?

When you operate a website, providing a smooth reading experience for users is one of the key factors in enhancing website stickiness.When a user finishes reading a document, if they can easily jump to the previous or next related article, it will undoubtedly greatly increase their stay time on your website.AnQiCMS (AnQiCMS) understands this and provides very intuitive and powerful `prevArchive` and `nextArchive` tags to help you easily implement this feature.

2025-11-08

How to display article title, content, images, etc. on the document detail page using the `archiveDetail` tag?

Manage website content in Anqi CMS, the document detail page is undoubtedly the core position for users to obtain information.How to present each carefully written article, its title, content, images, and various additional information accurately and vividly to the user, this requires the clever use of our `archiveDetail` tag.This tag is specifically designed to display the details of a single document, and its flexible use will help you easily build a feature-rich and smooth experience detail page.

2025-11-08

How does the `archiveList` tag display the article list based on categories, recommended attributes, or custom sorting?

In the Anqi CMS template system, the `archiveList` tag is the core tool for building dynamic content lists.Whether it is a blog article list, product display page, or news information module, `archiveList` can help you accurately filter, sort, and present content according to your diverse needs, bringing vitality to your website content area.

2025-11-08

How to build a complex search interface for product filtering or property filtering using the `archiveFilters` tag?

In the era of content explosion, when users visit websites, they often hope to quickly find the content they are interested in.Whether it is browsing a large number of products on e-commerce platforms or looking for housing that meets your preferences on real estate websites, a powerful and easy-to-use filtering and search interface is the key to improving user experience. AnQiCMS (AnQiCMS) knows this and provides a powerful `archiveFilters` tag for this purpose.This tag can help you easily build a complex product or property filtering interface, making your website content more discoverable and interactive

2025-11-08

How to display the associated tags of the `tagList` and implement a tag cloud effect?

## Utilizing AnQiCMS's `tagList` tag, easily implement document association and tag cloud display Tags play a crucial role in website content operations.They can not only help users quickly find the content they are interested in, improve the convenience of site navigation, but also optimize the search engine's understanding of the website's content through keyword aggregation, thereby bringing better SEO performance.AnQiCMS fully considered this requirement, built-in powerful tag features, and provided flexible template tags `tagList`

2025-11-08

How to retrieve and display the details of a specific `tagDetail` tag?

AnQiCMS (AnQiCMS) provides a series of powerful template tags to help website operators efficiently display content.Among them, the `tagDetail` tag is a key tool for obtaining and displaying specific tag details.Whether it is to build a beautiful tag detail page or to refer to related data of tags on other pages, `tagDetail` can provide a flexible and intuitive solution.

2025-11-08

How does the `tagDataList` tag display all document lists under a specific tag?

In Anqi CMS, managing and displaying content, the tag (Tag) is undoubtedly a very practical tool.It can help us organize documents more flexibly, realize multi-dimensional content aggregation, and greatly benefit the improvement of the website's SEO performance and user experience.When we need to display a list of all documents under a specific tag page, or at any location on the website, the `tagDataList` tag is an indispensable tool.###

2025-11-08