How to get and display the custom parameters of a specified document (such as author, source)?

Calendar 👁️ 72

When using AnQi CMS to manage your website content, you may find that relying solely on default fields such as title, content, and abstract is not enough to fully meet the needs of personalized display.For example, you would like to display information such as 'author' and 'source' on the article detail page, or show specific parameters such as 'material' and 'size' on the product page.The Anqi CMS provides powerful custom parameter functionality, allowing you to easily add, manage, and display these personalized information for different types of documents (such as articles, products).

This article will introduce in detail how to obtain and display custom parameters of specified documents in Anqi CMS, such as authors, sources, etc., to help you create a more rich and customized content display.

One, configure custom parameters and enter content in the background

To obtain and display custom parameters, you first need to configure them in the Anqi CMS backend. This process is divided into two steps: defining the parameters and then entering the values of these parameters for the document.

1. Define custom fields of the content model

Custom parameters are associated with the 'Content Model'. Each content model (such as 'Article Model', 'Product Model') can have its own unique custom fields.

  • Enter content model management:Log in to the AnQi CMS backend and navigate to“Content Management”Menu, then click“Content Model”.
  • Select or create a model:Here, you can choose to edit an existing content model (such as 'Article Model') to add new fields, or create a new content model.
  • Add custom field:In the selected content model editing page, find“Content model custom field”the area, click “Add Field”. You will see the following key settings:
    • Parameter name:This is the Chinese name displayed on the backend interface for operators, such as "article author", "source of content".
    • Call field:This is the unique identifier used to call this parameter in the front-end template, it must use letters, it is recommended to use camel case or lowercase underscore naming, for exampleauthor/source/materialThis field name is crucial, it will be used when the front-end is called.
    • Field type:Choose the appropriate field type according to the data you need to store, such as 'Single-line text' (for authors, sources), 'Multi-line text' (for longer introductions), 'Number', 'Single choice', 'Multiple choice', or 'Dropdown selection', etc.
    • Mandatory?:Determine whether the field is required based on business requirements.
    • Default:If the field has common values, you can set a default value.
  • Save configuration:After completing the field settings, be sure to click the save button to make the changes take effect.

2. To enter custom parameter values for the document

After defining custom fields for the content model, you can fill in specific content for these fields when publishing or editing the document corresponding to the model.

  • Enter the document editing interface:Navigate to“Content Management”, click“Publish document”Or edit an existing document.
  • Fill in custom parameters:Below the document editing page, there will be a:“Other Parameters”The collapsed area. Expand this area to see the custom fields defined for the content model, as well as the corresponding input boxes or options.Here, you can fill in information such as 'article author', 'content source', etc. for the current document.
  • Save the document:After filling in, save the document. The values of these custom parameters will be stored with the document.

Chapter 2: Retrieve and display custom parameters in the front-end template

After configuration and entry are completed, the next step is how to display these custom parameters on the website front-end page (usually the document detail page).Aq CMS provides powerful template tags, making this process very flexible.

Generally, you need to add the following code in the directory under your template.{模型table}/detail.htmlfor examplearticle/detail.htmlorproduct/detail.htmlAdd the following code to the file.

1. Directly call the specified custom parameters (recommended for simple scenarios)

For specific fields like 'author' or 'source' that are displayed only once on the page, the most direct method is to usearchiveDetail.

Assuming you have defined the "author" (call field asauthor) and "source" (call field assource) two custom fields.

{# 在文档详情页,您可以直接使用 archive 对象来调用自定义字段 #}
<p>作者:{{ archive.author }}</p>
<p>来源:{{ archive.source }}</p>

{# 或者,使用 archiveDetail 标签,这在当前页面不是文档详情页,但您知道文档ID时非常有用 #}
<p>作者:{% archiveDetail with name="author" %}</p>
<p>来源:{% archiveDetail with name="source" %}</p>

{# 如果自定义参数的内容是富文本或 Markdown 格式,需要加上 |safe 过滤器,Markdown 内容还需 |render 过滤器 #}
<div class="introduction">
    产品简介:{{ archive.introduction|render|safe }}
</div>

Description:

  • In the document detail page, the system usually automatically provides a variable namedarchivewhich contains all the information of the current document, including custom parameters. You can access{{ archive.调用字段名 }}in the form of direct access.
  • {% archiveDetail with name="调用字段名" %}This approach is more general, regardless of whether the current page is directly a document detail page, as long as the system can identify the document context or you specify a document ID, it can obtain the data.
  • |render|safeIf your custom field type is a rich text editor, and the content may contain HTML tags or Markdown syntax, in order for this content to be displayed correctly rather than as plain text output, you need to add|safeFilter. If the Markdown editor is enabled at the same time, it needs to be enabled first|renderthen|safe.

2. Loop through all custom parameters (for dynamic display)

If you want to dynamically display all the custom parameters of a document in an area, for example, to display all specifications uniformly on a product detail page, thenarchiveParamsThe label will be very convenient. It will return a list of custom parameters, and you can loop through them to display their names and values.

<div class="custom-parameters">
    <h3>详细参数</h3>
    {% archiveParams params %}
    {% for item in params %}
        <p><strong>{{ item.Name }}:</strong> {{ item.Value|safe }}</p>
    {% endfor %}
    {% endarchiveParams %}
</div>

Description:

  • {% archiveParams params %}It will retrieve all the custom parameters defined in the current document and assign them toparamsVariable.
  • paramsIt is an array object, each element of which containsName(parameter name, such as "article author") andValue(Parameter value).
  • By{% for item in params %}Loop, you can take each parameter name and value one by one to display.
  • Similarly,|safeThe filter is also very important here to prevent the parameter value from containing HTML content that needs to be parsed.

Step 3: Usage Tips and Precautions

  • Call field name consistency:Make sure the name used to define the "call field" in the background is exactly the same as the name you use when calling it in the template (including case).
  • Data type match: When defining field types in the background, please select according to the actual content. For example, if the custom field is a multi-select type, then on the front enditem.ValueMay be a comma-separated string, you may need to perform additional processing (such as using|split:","a filter to convert it into an array and then iterate over it).
  • Template cache:After modifying the template file, if the page does not update immediately, please try to clear the AnQi CMS system cache or browser cache.
  • Style beautification:The above code is just for functional implementation, in actual application, you also need to beautify these custom parameters through CSS to keep them consistent with the overall style of the website.

By using the above method, you can fully utilize the custom parameter function of Anqi CMS to add more dimensions and personalized display to your website content, thereby enhancing user experience and content value.


Frequently Asked Questions (FAQ)

Q1: Why do I not see the custom parameter I set in the background in the "Other parameters" page of the document editing page?A1: Please check if you haveThe content model of the current documentAdded custom parameters. For example, if you are editing an "article", the custom parameters must be defined under the "article model".In addition, make sure to click the save button after defining custom fields, and you may need to refresh the page to display them.

**Q2: When I call a custom parameter in the template, it displays plain text without parsing HTML tags or Markdown content

Related articles

How to display related documents or search results on the article list page?

In website operation, how to make visitors find the content they are interested in faster, or seamlessly discover more related information after browsing an article, is the key to improving user experience and website stickiness.AnQiCMS (AnQiCMS) provides powerful and flexible template tags that can help us easily implement displaying related documents or search results on the article list page, thus building a more intelligent and interactive website.### Smartly using content list tags to present dynamic information One of the core advantages of AnQi CMS lies in its highly customizable template system

2025-11-08

How to implement pagination for article lists and limit the number of items per page?

In website operation, especially when managing a large amount of content, the pagination display of the article list is an indispensable function.It not only makes it easier for users to browse content, avoids the problem of too much data loading on a single page leading to slow speed, but also improves the overall user experience and SEO friendliness of the website.In AnQi CMS, it is very intuitive to implement pagination for the article list and flexibly control the number of items per page. Next, we will explore how to implement pagination for the article list in the Anqi CMS template and limit the number of articles displayed per page.--- ### Efficient Content Management

2025-11-08

How to filter tags through document parameters to achieve a combination display of list content with multiple conditions?

In content operation, we often need to display lists of content with different themes and properties, and allow visitors to filter according to their own needs. For example, a real estate website may need to filter listings by "house type", "location", "area range", and other multi-dimensional combinations.If each time is organized manually or developed custom, it is not only inefficient but also difficult to maintain.AnQiCMS (AnQiCMS) provides a flexible and powerful document parameter filtering mechanism that can help us easily achieve this combination display of list content with multiple conditions. Next

2025-11-08

How to display associated categories and tags lists on the article detail page?

When managing website content in AnQi CMS, the article detail page is the core page for users to obtain information.In addition to the content of the article itself, displaying the category information and related tag list of the article to the visitor can greatly improve the user experience, help visitors quickly understand the context of the article, and effectively enhance the internal link structure of the website, which is greatly beneficial for search engine optimization (SEO).Next, we will discuss how to flexibly display these related information on the article detail page of Anqi CMS.AnQi CMS uses an intuitive and powerful template tag system

2025-11-08

How to get and display the list of all documents associated with a specified Tag?

Manage content in AnQi CMS, besides organizing through categories, flexibly using the "Tag" feature is also the key to improving the aggregation ability of website content and user experience.Tags can connect documents of different categories, different models, but with the same theme, providing visitors with more ways to discover content.How can we specifically retrieve and display the list of all documents associated with the specified tags?Next, we will delve deeper into this practical skill. ### Understanding the Tag System of AnQi CMS The tag design of AnQi CMS is very flexible, it does not depend on any specific category or model

2025-11-08

How to retrieve and display the list of friend links of a website?

In website operation, friendship links play an important role in connecting each other, promoting traffic, and improving search engine rankings.A well-maintained, clear display of the friendship link area, which not only reflects the openness of the website, but also provides users with more valuable jump paths.AnQiCMS provides users with a convenient friend link management feature, allowing you to easily obtain and display these links on your website. ### Manage your friend links: Backend settings Before starting the front-end display, we need to make sure that the friend links have already been configured in the Anqi CMS backend. Usually

2025-11-08

How to add and display a captcha in the comment or message form to prevent spam?

When operating a website, spam comments and malicious messages are always a headache, as they not only affect user experience but may also damage the professional image of the website.Fortunately, AnQi CMS provides a simple and effective way to solve this problem - that is to add a captcha to the comment or message form.This can greatly enhance the security of the website, filtering out most automated spam information.Below, let's take a detailed look at how to add a captcha to your comment and message form in Anqi CMS.This process can be divided into two steps, which is very intuitive and easy to operate.### Step 1

2025-11-08

How to retrieve and display details of a specific category, including description, content, and Banner image?

When operating a website, we often need to display unique content for different category pages, such as a product category may have a detailed introduction and an eye-catching Banner image, while a news category may focus more on a concise description.AnQi CMS provides a flexible mechanism that allows us to easily retrieve and display detailed information about specific categories, including descriptions, content, and Banner images.### Backend settings are fundamental: enriching categories Before displaying category details on the frontend, we need to fill in this information in the Anqi CMS backend

2025-11-08