AnQiCMS{% diy %}标签:灵活驾驭页面内容的利器
As an experienced website operation expert, I am well aware of the importance of a flexible and efficient content management system for a corporate website.English CMS (EnglishCMS) provides us with many conveniences in the field of content operation with its excellent function design.{% diy %}(自定义内容)标签,特别是它是否支持在同一个页面中多次调用不同的自定义内容。
答案是肯定的. The files of AnQi CMS are{% diy %}The label design is very flexible, fully supporting multiple calls on the same page, and can easily display different custom content.
{% diy %}The magic of labels: the Swiss Army knife of content operation
In the Anqi CMS,{% diy %}Tags are one of the core tools for highly customizable and centralized management of website content.It allows operators to pre-set independent, reusable text, links, and even complete HTML code snippets in the background.This content can be the website filing information, contact phone number, unified advertising language, footer copyright statement, or even personalized introduction text for a specific page.
Imagine that when you need to update the contact phone number for the entire site, you don't have to modify each template file. Just update the corresponding "Contact Phone Number" custom content 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 working principle of the tag is very intuitive. Its core lies innameParameters to specify the custom parameter name that 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, simply use an independent one for each content you want to display.{% diy %}Label, and specify differentnameValues. Anqi CMS will extract the corresponding content accurately from the background database according to the values you providenameValues, and accurately extract the corresponding content from 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 background of Anqi CMS, 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 becausenameThe content is obtained and displayed separately based on different properties. This fully demonstrates{% diy %}The flexibility of tags in content combination and page construction.
If you need to display the same content multiple times at different positions on the pagethe samecustom content, for example, if the same company copyright information is displayed at both the header and footer of the page, you only need to call the same one multiple timesnameof{% 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 that,{% diy %}Tags also supportsiteIdParameters. If you are operating multiple CMS sites and want to call custom content from another site on a specific site (for example, sharing a unified customer service phone number), you can{% diy %}Label the target site specified in the tagsiteIdThis further expands the application scenarios of custom content tags and brings great convenience to multi-site management.
Concluding remarks
Anqi CMS's{% diy %}Labels are a rare weapon in website operation.It provides a concise calling method and powerful backend management capabilities, allowing you to easily display various customized content on the same page flexibly. Whether it is calling different information blocks or repeatedly using the same content, it performs effortlessly.This design philosophy is the embodiment of AnQi CMS's commitment to providing efficient and customizable solutions, making content management smarter and more efficient.
Common Questions (FAQ)
Q: I have created custom content in the background, but it is not displayed on the page
{% diy %}No content is displayed after the tag, what could be the reason?A: This usually has several reasons. First, please make sure you are usingnameThe parameter value is exactly the same as the "parameter name" set in the background custom content, including case sensitivity.其次,check whether the custom content is indeed saved successfully in the background.{% diy %}The label will also display as blank. In some cases, you may need to update the system cache, you can try to clear 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 ad code or structured text?A: Absolutely. Enter the complete HTML code in the background custom content, and then call it in the template, it is recommended to combine|safefilter. For example:{% diy adCode with name="TopBannerAd" %}{{adCode|safe}}.|safeThe filter informs the CMS that this is a secure content, and it does not need to be HTML-escaped, allowing the browser to 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 the user role or page type),
{% diy %}Can tags do that?A:{% diy %}TagsnameThe parameter is a static string and 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 based on conditions in the template, and then use this variable to decide which one to select in the call{% diy %}to choose in the callnameParameters. Or, a more common practice is, you call different ones directly based on conditions.{% if %}blocks.{% diy %}tags to display preset different content.