AnQiCMS'{% diy %}Label: A powerful tool for flexibly controlling page content
As an experienced website operations expert, I am well aware of the importance of a flexible and efficient content management system for a corporate website.AnQiCMS (AnQiCMS) provides us with many conveniences in the field of content operation with its excellent functional design.Today, let's delve deeply into a feature that is often inquired about but is extremely practical{% diy %}(Custom content) label, especially whether it supports multiple calls of different custom content on the same page
The answer is yes. Anqi CMS's{% diy %}The tag is designed to be very flexible, fully supporting multiple calls on the same page, and can easily display different customized content.
{% diy %}The versatility of the tag: the Swiss Army knife for content operation
In AnQi CMS,{% diy %}Tags are the core tools for highly customized and centralized management of website content.It allows operation personnel to pre-set independent, reusable text, links, and even complete HTML code snippets in the background.This content can be the record information of the website, contact number, unified advertising language, footer copyright statement, or even a personalized introduction text for a specific page.
Imagine, when you need to update the contact phone number of the entire site, you do not need to modify each template file. Just update the corresponding custom contact information in the background once, and all pages that call this content will be synchronized updated.This greatly improves the efficiency of content maintenance and reduces the risk of errors.
How to call different custom content on the same page?
{% diy %}The principle of the tag is very intuitive. Its core lies in the way thatnameParameters can be used to specify the "custom parameter name" you create in the background. Each uniquenamevalue corresponds to a specific piece of custom content.
Therefore, when you need to display multiple different custom contents on the same page, you just need to use an independent{% diy %}Label and specify differentnamevalues. Anqicms will accurately extract the corresponding content from the background database according to the values you provide and display it on the page.namefrom the background database and present it on the page.
For example, your website homepage may need to display three different custom contents such as 'Company Profile', 'Contact Email', and 'Latest Announcement Title'. In the Anqi CMS backend 'Global Settings' or 'Content Settings', you can create three custom parameters separately, for example namedCompanyName/SupportEmailandLatestNewsTitle. Then in your homepage template, you can call them like this:
<!-- 调用公司名称 -->
<p>欢迎访问:{% diy companyName with name="CompanyName" %}{{companyName}}</p>
<!-- 调用支持邮箱 -->
<p>技术支持:<a href="mailto:{% diy email with name="SupportEmail" %}{{email}}">{% diy email with name="SupportEmail" %}{{email}}</a></p>
<!-- 调用最新公告标题 -->
<h2>最新动态:{% diy newsTitle with name="LatestNewsTitle" %}{{newsTitle}}</h2>
In this example, even if these three tags appear consecutively on the same page, they will be becausenameThe difference in properties allows for the retrieval and display of three completely unrelated customized contents. This fully demonstrates{% diy %}The flexibility of tags in content composition and page construction.
If you need to display the same content multiple times at different positions on the pageThe same paragraphCustom content, for example, if you want the same company copyright information to be displayed at the top and bottom of the page, you can simply call the same one multiple times.nameof{% diy %}Label it. No matter how many times it is called, it will always display the content you set in the background.
<!-- 页面顶部版权信息 -->
<header>
<span>{% diy copyright with name="SiteCopyright" %}{{copyright}}</span>
</header>
<!-- 页面底部版权信息 -->
<footer>
<span>{% diy copyright with name="SiteCopyright" %}{{copyright}}</span>
</footer>
CombinesiteIdParameters, to achieve content sharing across multiple sites
It is worth mentioning,{% diy %}Tags also supportsiteIdParameter. If you are operating multiple Anqi CMS sites and want to call a custom content of another site on a certain site (for example, sharing a unified customer service phone number), then you can{% diy %}Labeling the target site specified in the tagsiteIdThis further expands the application scenario of custom content tags, bringing great convenience to multi-site management.
Conclusion
Of Security CMS{% diy %}Tags are a rare tool in website operations. They allow you to easily display various customized content flexibly on the same page, whether it's calling different information blocks or reusing the same content multiple times, you can do it with ease.This design philosophy is the embodiment of AnQi CMS's commitment to providing efficient and customizable solutions, making content management more intelligent and efficient.
Frequently Asked Questions (FAQ)
Q: I created custom content in the background, but the label is not displayed on the page
{% diy %}What could be the reason for no content display after the label?A: There are usually several reasons. First, make sure you are using in the template.nameThe parameter value is exactly the same as the custom content setting of the "parameter name" in the background, including case sensitivity.Next, check whether the custom content has been saved successfully in the background.If the content is blank,{% diy %}The label will also be displayed as blank. In some cases, you may need to update the system cache, and you can try clearing the cache after refreshing the page in the "Update Cache" feature in the background.Q:
{% diy %}Can tags be used to store and display HTML code? For example, a complex advertisement code or structured text?A: Absolutely. Enter the complete HTML code in the background custom content, and then when calling the template, it is recommended to combine|safea filter. For example:{% diy adCode with name="TopBannerAd" %}{{adCode|safe}}.|safeThe filter informs the Anqi CMS that this is safe content, which does not require HTML escaping, so that the browser can correctly parse and render the HTML code you define.Q: If I want to dynamically decide which custom content to call (for example, based on user role or page type),
{% diy %}Can the tag do that?A:{% diy %}label'snameThe parameter is a static string, it cannot directly accept template variables as its value. But you can combine{% if %}or{% set %}Label, indirectly implements dynamic selection. For example, you can set a variable in the template based on conditions, and then use this variable to decide which one to call in different{% diy %}the call to choose which onenameParameter. Or, a more common practice is to call different{% if %}blocks based on conditions.{% diy %}tags to display predefined different content.