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

Calendar 👁️ 60

As an experienced website operations expert, I know 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 customization, especially as it provides through{% diy %}The functionality of obtaining custom parameters by tags 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.

{% diy %}Label: The core of custom parameters is located here

In AnQi CMS,{% diy %}Tags are a powerful tool to get the parameters you customize in the background.These custom parameters are usually defined in modules such as 'System Settings' or 'Contact Information Settings', and you can create any number of key-value pairs (parameter names and values) according to your business needs.For example, you can define a 'Company Slogan', a 'Special Service Icon URL', or even a 'Segment containing HTML advertisements'.

The basic syntax of its use is:{% diy 变量名称 with name="字段名称" %}

here,nameThe attribute corresponds to the "parameter name" you set in the background, and变量名称It is the local variable used in the front-end template to receive and process this parameter value. For example, if you set a custom parameter named "CompanySlogan" in the background, with a value of "We illuminate life with innovation", then in the front-end template, you can obtain it in the following way:

{% diy slogan with name="CompanySlogan" %}

Once a parameter is assigned tosloganyou can use this variable anywhere in the template{{ slogan }}Output its content. This mechanism of separating data from the view is the basis for flexible layout and style control.

From backend to frontend: obtain custom parameters and structure content.

The first step in front-end layout and style control is to ensure that custom parameters can be correctly obtained and integrated into the HTML structure.{% diy %}The tag is born for this. It can receive parameter values that can be plain text, image URLs, or even rich text content containing HTML fragments.

For simple text content, you can directly output:<h1>{% diy with name="PageTitle" %}</h1>

But to better control the layout and style, we usually assign it to a variable and then wrap the variable content in HTML tags with specific semantics and class names.

The core strategy is:Try to use semantic HTML tags to wrap content and define styles through CSS classes (class).This not only conforms to the Web standard, but also makes maintenance and expansion easier.

Practice: Layout and style control of various custom parameters

Let's look at several specific examples to see how different types of custom parameters can be beautifully typeset and styled on the front end.

1. A plain text type custom parameter (such as a company slogan)

Assuming you have customized a parameter in the background, namedCompanySloganIts value is "AnQi CMS: Your Content Management Expert". You want to display this slogan prominently at the top of the website.

Backend definition: Parameter name:CompanySloganParameter value:安企CMS:您的内容管理专家

Front-end template (combined HTML and CSS):

`html {% comment %} Get the custom parameter of CompanySlogan {% endcomment %} {% diy sloganText with name=“CompanySlogan”

Related articles

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

Anqi CMS, as an enterprise-level content management system known for its efficiency and customization, its powerful template tag feature is undoubtedly a helpful tool for content operators and website developers.In daily website operations, we often encounter the need to quickly adjust some global and site-level configuration information, such as the company's slogan, a link to a specific event, or a temporary announcement text, etc. These pieces of information do not require complex classification and models like article content, but are more flexible than hard-coded in templates.This is provided by Anqicms with `{% diy

2025-11-06

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

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

The `{% diy %}` tag supports multiple calls to different custom content on the same page?

The `{% diy %}` tag of AnQiCMS: a powerful tool for flexibly handling web page content As an experienced website operation expert, I fully understand the importance of a flexible and efficient content management system for a corporate website.AnQiCMS (AnQiCMS) with its excellent feature design provides us with many conveniences in the content operation field.

2025-11-06