How should the `name` parameter of the `{% diy %}` tag be set correctly to retrieve custom data from the backend?

Calendar 👁️ 68

AnQiCMS (AnQiCMS) is an efficient and flexible content management system, with its powerful custom functions being an important treasure for website operators to improve efficiency and achieve personalized display. In daily content operations, we often encounter situations where we need to call back-end preset but non-standard field data, and{% diy %}The label is born for this. Then, what parameters should be set to accurately obtain the customized data from the background? Let's explore in depth.name参数究竟该如何设置,才能准确无误地获取到后台的自定义数据呢?让我们深入探讨一番。


Revelation{% diy %}Tag: Unlock the custom data treasure of the background

in the AnQi CMS template world,{% diy %}Tags play a very practical role: they allow us to flexibly retrieve those custom global data that do not belong to the system's predefined fields but are also wanted to be displayed on the front-end page.Imagine that you might want to display a company's annual slogan at the footer of the website or showcase a special event entry in the sidebar. This information is usually not bound to specific articles or products but rather as an integral part of the website.{% diy %}Tag is your powerful assistant

nameThe core secret of the parameter: accurate matching of background settings

Use correctly{% diy %}Understanding the tag is the most critical stepnameParameter setting rules. In short,nameThe value of the parameter must beExact matchIn the “Global Settings” or “Contact Information Settings” modules and others in the AnQi CMS background,The parameter name filled in when adding a custom parameter.

This means that when you create a custom data item in the background, the unique parameter name assigned to it is the front end{% diy %}in the tagnameThe expected parameter value. It is the bridge connecting backend data with the frontend template.

Data source: Where to set custom data in the backend?

In order to{% diy %}The label has data to be retrieved, and we first need to make the corresponding settings in the Anqi CMS backend. Usually, these global custom data are configured at the following two main locations:

  1. Global settings custom parameters (recommended for website general information)Log in to the backend, find the "Global Settings" under the "Backend Settings" menu.In here, you will see an area for 'custom setting parameters'.Click the 'Add' button, and you can define new custom data items.

    • Parameter name:This is the most important field! For example, you can fill inCompanySlogan/SupportEmail/WeChatOfficialAccountAnd. This name will be used directly as{% diy %}TagnameThe value of the parameter.
    • Parameter value:Fill in the actual content of the parameter, for example您的信任,我们守护!or[email protected].
    • Note:For internal management, convenient for you to remember the purpose of the parameter.
  2. Custom parameters in the contact information settings (recommended for expanding corporate contact information)Similar to the "Global SettingsIf you need to add specific contact information in addition to the default contact information (such as phone number, address), such as Telegram account, Skype ID, etc., you can add it here.The setting logic is consistent with the custom parameters in the global settings.

Tip:When filling in the "parameter name", although AnQi CMS will automatically convert Chinese characters or space-containing parameter names to camel case in some cases (for example, "company slogan" may be converted toCompanyKouHaoBut to maintain the conciseness and readability of the template code, it is strongly recommended to use it directlyEnglish letters, numbers, and underscoresThe combination as "parameter name", and follow camel case naming conventions (such asCompanySlogan), so as to ensure the consistency and maintainability of front-end and back-end calls

Practical demonstration: Correct settingnameParameter

Let's look at how to operate with a specific example.

Scenario:You want to display the company's annual slogan at the footer of the website, which needs to be changeable in the background at any time.

Step 1: Set custom parameters in the background

  1. Log in to the AnQi CMS background.
  2. Navigate to "Background Settings" -> "Global Settings".
  3. In the "Custom Setting Parameters" area, click the "Add" button.
  4. In the popped-up form:
    • Parameter name:Fill inAnnualSlogan(Note that we used camel case naming here).
    • Parameter value:Fill in科技赋能未来,智慧连接世界.
    • Note:Fill in公司年度宣传口号.
  5. Click "OK" to save.

Second step: Use in the front-end template{% diy %}TagNow, you can use it in your template file (such aspartial/footer.htmlor any other location where you want to display the slogan{% diy %}tag to retrieve and display this annual slogan:

{# 直接输出自定义参数的值 #}
<p class="company-slogan">{% diy with name="AnnualSlogan" %}</p>

{# 或者,将值赋给一个变量再输出,方便进一步处理 #}
{% diy currentSlogan with name="AnnualSlogan" %}
<p class="company-slogan-dynamic">{{ currentSlogan }}</p>

Run the website, you will see this in the footer:

<p class="company-slogan">科技赋能未来,智慧连接世界</p>
<p class="company-slogan-dynamic">科技赋能未来,智慧连接世界</p>

See, as long asnameThe value of the parameter (AnnualSlogan) is exactly the same as the 'parameter name' set in the background,{% diy %}Labels can accurately extract the corresponding "parameter value" to the front-end page.

Why choose{% diy %}: Enhancement of operational efficiency

Master correctly{% diy %}Especially the usage of labels,nameParameter settings mean that:

  • Centralized management:All non-content main custom information can be configured uniformly in the background, avoiding hard coding in the template and improving management efficiency.
  • Flexible iteration: When this information needs to be updated, it only needs to be modified once in the background, and all calls to the site will be automatically synchronized without touching the code.{% diy %}The places labeled will be automatically synchronized and updated without touching the code.
  • Reduce risk:Reduced the frequency of directly modifying template files, thereby reducing the risk of website problems caused by misoperation.
  • Content and presentation are separated:Further realized the effective separation of website content and template performance, allowing content operations and template design to run in parallel without contradiction.

Frequently Asked Questions (FAQ)

Understand{% diy %}label'snameDuring the parameter setting process, you may encounter some questions. Below are several common questions and their answers:

1.{% diy %}Which types of data can the tag retrieve? For example, can it retrieve images or complex HTML fragments?

{% diy %}The tag is mainly used to retrieve the "custom parameters" stored in the background.Text stringData.This can be plain text, a URL link, a phrase, or even a short piece of HTML code.{% diy %}Labels will output these strings unchanged. In the template, you can combine<img>Labels can use the output image link, or use|safeThe filter safely renders HTML fragments. However, it does not directly support complex rich text editor content or file upload.

2. In the multi-site mode of AnQi CMS,{% diy %}How to label to get data from a specific site?

{% diy %}Tag supportsiteIdParameters. If you have enabled multi-site management in the background and want to get custom data from a non-current site, you can specifysiteIdTo implement. For example,{% diy with name="AnnualSlogan" siteId="2" %}Will try to get the site with ID 2.AnnualSloganParameter. If not specified,siteIdIt will default to getting the custom data of the current site.

3. If the backend custom parameter name contains Chinese or special characters, the front endnamehow should the parameter be filled in?

According to the design of AnQi CMS, when setting custom parameters in the background, it is recommended that the "parameter name" be a combination of letters and numbers. Although the system will automatically convert Chinese parameter names to camel case when processing custom parameters in "global settings" and "contact information settings" for template calls, to avoid unnecessary confusion and potential encoding issues,It is strongly recommended to use English camel case naming conventions when setting "parameter name"for exampleCompanySloganinstead of公司口号) in the front-endnameParameters can be directly matched, ensuring that the code is clear and the call is accurate. If the backend has already used Chinese as parameter names, you need to check where it is set specifically, and use the camel case naming form converted from it.nameFill in the parameter.

Hope this article can help you better understand and use Anqi CMS.{% diy %}Tags, make your website operation more skillful.

Related articles

How to use the `{% diy %}` tag to display custom information configured on the back-end page?

As an experienced website operations expert, I fully understand how important the flexibility and update efficiency of website content are in the increasingly fierce online competition.AnQiCMS (AnQiCMS) with its powerful functions and friendly template system provides us with many operational tools.Today, let's delve into one of the very practical 'magic box' - the `{% diy %}` tag, and see how it helps us easily control the custom information of the front-end page, making website content operation more intelligent and efficient.

2025-11-06

What is the core use of the `{% diy %}` custom content tag in AnQiCMS?

## Core Usage Deep Analysis of Custom Content Tags in Anqi CMS `{% diy %}` As an experienced website operations expert, I fully understand the importance of a flexible and scalable content management system for efficient website operations.AnQiCMS (AnQiCMS) stands out among many CMS products with its powerful customization capabilities.In its rich template tag system, the `{% diy %}` (Do It Yourself) custom content tag is undoubtedly a core tool for achieving high website personalization and operational efficiency optimization.

2025-11-06

How to ensure that all external social media links called by the `contact` tag open in a new window when clicked?

As an experienced website operations expert, I am well aware of the importance of website details for user experience and brand image.In content operation, we often need to guide users to visit external social media platforms to expand influence or provide more interactive channels.AnQiCMS (AnQiCMS) takes advantage of its flexible template tag system, making such operations intuitive and efficient.However, a common detail that is often overlooked is: How to ensure that these external links open in a new window or tab when clicked, thus avoiding users leaving your main site?Today, let's delve deeply into this issue

2025-11-06

Can I flexibly implement the `contact` tag of AnQiCMS to display multiple WhatsApp contacts on the page?

How to flexibly display multiple WhatsApp contacts in AnQiCMS?Unlock the advanced usage of the `contact` tag In today's global business environment, WhatsApp has become an important tool for efficient communication between businesses and customers.Whether it is for sales consultation, customer service, or specialized support for different products or regions, businesses may need to display multiple WhatsApp contact methods on their websites.The Anqi CMS is a powerful and flexible content management system that naturally also provides a convenient way to display contact information.

2025-11-06

Under AnQiCMS multi-site management, how to accurately call the custom content of a specific site using the `{% diy %}` tag?

In the powerful ecosystem of Anqi CMS, multi-site management is undoubtedly one of its core highlights, giving enterprises the ability to operate multiple brands or sub-sites on the same platform.However, in the process of content operation, we often encounter such needs: how to flexibly call specific custom content from another sub-site in the template of the main site?At this point, the `{% diy %}` tag, combined with its clever `siteId` parameter, has become our powerful assistant in achieving this goal.

2025-11-06

If the custom content information is not set on the backend, what will the `{% diy %}` tag return on the front end?

AnQiCMS (AnQiCMS) with its flexibility and powerful customization capabilities has become the preferred tool for many enterprises and content operators.The `{% diy %}` tag is the key to displaying dynamic content, allowing us to customize various information in the background and present it on the website front end.What if the backend does not set a specific custom content, and the front end uses the `{% diy %}` tag to call it?As an experienced website operations expert, I am happy to delve deeply into this mechanism.### Understand `{%

2025-11-06

How to implement a custom global website title or subtitle display using the `{% diy %}` tag?

## How to cleverly use the `{% diy %}` tag of AnQi CMS: Create personalized global website title and subtitle Maintaining brand image consistency and content update flexibility is crucial in website operation.Especially the global title and subtitle of the website, which are not only the first impression visitors have of the website content, but are also key elements of search engine optimization (SEO).

2025-11-06

`{% diy %}` label and the system built-in `{% system %}` or `{% contact %}` label what are the similarities and differences?

AnQi CMS as an efficient enterprise-level content management system, its template tag system provides great flexibility for content display.When building a website, we often need to fetch various data from the backend and display it on the frontend page.Among these, `{% system %}`, `{% contact %}`, and `{% diy %}` are all used to obtain information from the background configuration, but they have subtle differences in functional emphasis, data source, and application scenarios.Understanding these similarities and differences can help us use these tools more efficiently and rationally, creating a clear structure

2025-11-06