How to create and manage custom parameters for the `{% diy %}` tag in AnQiCMS backend?

Calendar 👁️ 65

AnQi CMS is a high-efficiency, customizable enterprise-level content management system, whose powerful template tag function is undoubtedly a good helper for content operators and website developers.In daily website operations, we often encounter the need to quickly adjust some global, site-level configuration information, such as company slogans, links to specific events, or temporary announcement texts, etc. These pieces of information do not require complex categorization and models like article content, but are more flexible than hardcoded in templates.This is provided by Anqi CMS{% diy %}The tag and its underlying custom parameter management mechanism is particularly important.

This article will delve into how to create and manage these supplies in the AnQiCMS backend.{% diy %}Label custom parameters and seamlessly apply them to the website front-end, helping you better utilize the flexibility of AnQiCMS to achieve quick response and efficient operation.

Understanding{% diy %}Label: Your customized information center

In the AnQiCMS template system,{% diy %}Labels play the role of a 'universal information box.' Unlike{% system %}The tag is used to retrieve system preset global information (such as website name, Logo, filing number), and is different from{% contact %}The tag is used to retrieve contact information (such as phone, email, address),{% diy %}Labels used to call the backendCustom text or links with global or semi-global properties added.

Imagine if your website needs to display a banner saying 'Summer Promotion Ongoing!' during a special period, or if you want to add a social media link that does not belong to the preset contact information, use{% diy %}Label配合custom parameters can easily be implemented without modifying any template code files, greatly improving operational efficiency.

Create and manage custom parameters in the AnQiCMS backend

To make{% diy %}Tags can be retrieved, and we first need to define these custom parameters in the AnQiCMS background. This process is very intuitive.

You will find that in the AnQiCMS backend,全局功能设置and联系方式设置these modules both provide the function of "custom setting parameters". This means,{% diy %}Labels can flexibly call the custom parameters you define in these two areas.This provides certain convenience for the logical classification of parameters, for example, custom links related to contact can be placed in the "Contact Settings", while other more general information can be placed in the "Global Function Settings".

Let us take the example of adding a custom parameter for a company vision in the "Global Feature Settings".

  1. Navigate to the settings pageFirst, log in to your AnQiCMS admin interface. In the left navigation bar, find and click系统设置and then select全局功能设置.

  2. Locate the custom parameter areaIn the "Global Feature Settings" page, scroll down and you will see a section named "Custom Setting Parameters". This is where we add personalized configurations.

  3. Add a new custom parameterClick添加自定义参数Button, at this time, a form will pop up or expand, for you to fill in parameter information.

    • Parameter NameThis is the most critical field, which determines the name used when calling this parameter in the template. It is recommended to use letters and follow camelCase naming conventions (such asCompanyMission/HolidayNoticeThis keeps the naming clarity, and it is convenient to call it in the template. Please note that this parameter name should be unique throughout the website to avoid confusion.
    • Parameter valueHere is the actual content you want to store, which can be plain text, HTML code snippets, URL links, and so on.For example, we can fill in 'leading industry innovation, empowering enterprise development'.
    • NoteThis is an optional but strongly recommended field. Here, you can briefly describe the purpose of this parameter, such as 'the core vision displayed to the public by the company', which is very helpful for team collaboration and future parameter maintenance.
  4. Save Changes: Click after filling in保存Button, your custom parameters have been successfully added and taken effect.

In the same way, you can add custom parameters related to contact information in the "Contact Information Settings", such as a specific WhatsApp group link or an online customer service time description.

Use in the front-end template{% diy %}Tag

After creating a custom parameter, the next step is to skillfully use it in the website template{% diy %}Tags are used to display this information. AnQiCMS template engine adopts the syntax similar to Django template engine, making the use of variables and tags very intuitive.

{% diy %}The basic usage of the tag is similar to{% system %}and{% contact %}By usingnameThe attribute specifies the parameter name to be called.

For example, we want to display the 'company vision' set just now in the header or footer of the website:

{# 直接输出自定义参数的值 #}
<p>我们的愿景:{% diy with name="CompanyMission" %}</p>

{# 将自定义参数的值赋值给一个变量,再进行输出和处理 #}
{% diy missionText with name="CompanyMission" %}
{% if missionText %}
    <p>我们的愿景是:{{ missionText }}</p>
{% else %}
    <p>暂无公司愿景信息。</p>
{% endif %}

In the above code snippet:

  • {% diy with name="CompanyMission" %}It will directly output the name ofCompanyMissionCustom parameter value.
  • {% diy missionText with name="CompanyMission" %}Then the value ofCompanyMissionthe parameter is assigned to a namedmissionTextThe template variable. The advantage of doing this is that you can make further logical judgments (such as{% if missionText %})、string processing(if AnQiCMS filters are supported)or used in conjunction with other page content, making the template more dynamic and robust.

Please note,{% diy %}All parameters supported by the tag, for examplesiteIdAlso applies to the invocation of custom parameters, if you need to manage multiple sites, you can specifysiteIdto retrieve the custom parameters of a specific site.

In this way, you can easily push various operational information, announcements, promotional slogans, etc., from the background to the front end of the website, achieving fast content updates and flexible management without touching a single line of code, which is the powerful convenience brought by AnQiCMS as an enterprise-level content management system.


Frequently Asked Questions (FAQ)

1.{% diy %}with the tag and{% system %}or{% contact %}What is the difference between tags? {% system %}and{% contact %}Tags are used to call the AnQiCMS systemPredefinedThe global information (such as website name, Logo, filing number) and contact information (such as phone, email) and...{% diy %}Tags are specifically used to call the "Global Function Settings" or "Contact Information Settings" in the backgroundCustom parameter areaParameters manually created, personalized, and non-presets. Simply put, the former is built-in items, and the latter are your extended items.

2. Can I use{% diy %}Add custom fields to specific articles or products?No.{% diy %}Tags are designed for site-wide or global custom parameters. If you need to add toa specific article, product, or other content modelAdd custom fields (such as the 'author' field of an article, the 'color' option of a product), you should内容管理-u003e内容模型Define these model fields. These model fields will be displayed when editing specific articles or products and are called through{% archiveDetail %}or{% archiveParams %}tags instead of{% diy %}.

3. If I call{% diy %}What will happen if the parameter does not exist?If{% diy %}The parameter name tried to be called is not defined in the background, AnQiCMS template engine usually returns an empty value or does not output any content, rather than throwing an error that causes the page to crash. To enhance the robustness of the template, you can use conditional judgment in the template (such as{% if yourDiyParameter %}Check for parameter existence or values to avoid displaying unnecessary or missing information.

Related articles

What are the functional differences between AnQiCMS' 'custom content tags' and traditional CMS 'custom fields'?

As an experienced website operations expert, I am well aware that the core of a content management system (CMS) lies in its ability to organize and present content.AnQiCMS is an enterprise-level content management system developed in Go language, with unique flexibility in content models.Today, let's delve into the functional differences between the 'Custom Content Tags' in AnQiCMS and the 'Custom Fields' of traditional CMS or AnQiCMS itself, hoping to help everyone understand more clearly how to use these tools to optimize content operation strategies.--- ###

2025-11-06

Does the `{% diy %}` tag support retrieving custom content created by the rich text editor and rendering it?

As an experienced website operation expert, and also a deep user of Anqi CMS, I am very happy to discuss with everyone the ability of the `{% diy %}` tag in processing rich text content rendering.In the flexible and powerful template system of AnQi CMS, understanding the characteristics of each tag is crucial for achieving accurate and efficient content display.

2025-11-06

How to ensure that the custom content obtained by the `{% diy %}` tag is safely output in the front-end template?

As an experienced website operations expert, I know that the flexibility of the Content Management System (CMS) is both an advantage and may bring potential security challenges.AnQiCMS is widely popular among many enterprises and content operators for its simplicity, efficiency, and powerful customizability.One of its core functions is to obtain custom content from the background through the `{% diy %}` tag, which greatly enriches the dynamism of the template.However, how to ensure that these custom contents are safely output in the front-end template and avoid potential risks is a problem that every operator must seriously consider.

2025-11-06

Does using the `{% diy %}` tag affect page loading speed or SEO?

In the daily operation of Anqi CMS, we often encounter questions about how template tags affect website performance and SEO effects.Today, let's delve into the usage of the `{% diy %}` tag and see if it really becomes a bottleneck for page loading speed or has a negative impact on search engine optimization.As an experienced website operation expert, I deeply understand that AnQiCMS, developed with high-performance architecture in Go language and rich SEO optimization tools as its core advantage, aims to provide an efficient and customizable content management solution. Therefore

2025-11-06

How to use the `{% diy %}` tag to get custom parameters and control formatting and styling on the front end?

As an experienced website operations expert, I am well aware that the flexibility of a Content Management System (CMS) is the key to improving operational efficiency and website performance.AnQiCMS (AnQiCMS) stands out in this aspect due to its excellent customizability, especially with the feature of obtaining custom parameters through the `{% diy %}` tag, which brings great convenience and imagination space for the layout and style control of front-end content.Today, let's delve into how to巧妙运用 this feature, making your website content both beautiful and functional.

2025-11-06

Can the `{% diy %}` tag be used to call custom configurations of specific modules, such as only for the article module?

In the practice of template development for Anqi CMS, the `{% diy %}` tag is used frequently, providing website operators with great flexibility to customize and call various information configured in the background.However, many developers may feel confused about whether it can accurately call a custom configuration for a specific content model such as "only for article modules".Today, as an experienced website operations expert, I will deeply analyze this mechanism based on the AnQi CMS documentation and guide you on how to correctly use template tags in different scenarios.

2025-11-06

How to set and get custom website sidebar content using the `{% diy %}` tag?

As an experienced website operations expert, I know that the flexibility of the website content management system is crucial for operational efficiency.AnQiCMS (AnQiCMS) provides us with many powerful content management functions with its concise and efficient architecture.Today, let's delve deeply into one of the very practical and flexible features - how to set and get custom website sidebar content using the `{% diy %}` tag.

2025-11-06

The value obtained by the `{% diy %}` tag, can it be further processed in the filter?

As an experienced website operation expert, I have accumulated rich experience in the practical application of AnQiCMS, and I particularly understand the importance of content flexibility to the vitality of a website.Today, let's delve into a question that many AnQiCMS users have been curious about: whether the custom value obtained from the `{% diy %}` tag can be further processed in template filters?In short, the answer is affirmative, and this ability greatly broadens the imagination space for AnQiCMS template customization and content operation.

2025-11-06