As an experienced website operations expert, I am well aware that it is crucial to flexibly manage and call various content in daily work.AnQiCMS (AnQiCMS) does an excellent job in this aspect, providing a series of powerful tags that make content operation effortless.{% diy %}Labels can be flexibly called on the front end of the website.
{% diy %}Tags, as the name implies, is the abbreviation of "Do It Yourself", and it plays the role of a universal tool in the Safe CMS, allowing you to centrally manage and call information that does not belong to the regular content system of articles, products, categories, etc., but needs to be repeated in multiple places on the website.This greatly enhances the maintainability and operational efficiency of the website, avoiding the update difficulties brought by hard-coded data in templates.
{% diy %}The custom information sources that labels can call
The backend design of Anqi CMS is very user-friendly, allowing you to create available in two main areas{% diy %}Label call custom parameter:
- Custom parameters in global function settings
- Custom parameters in contact information settings
Let's unfold them one by one.
1. Settings of global functions including custom parameters
In the AnQi CMS backend, you can find this area by navigating to "Backend Settings" -> "Global Function Settings".Here is the 'Custom settings parameters' section, which opens up a new dimension of content management.When the built-in system settings (such as website name, Logo, filing number, etc.) of AnQi CMS cannot meet the specific needs of your website, you can add them yourself here.
Types of custom information you can add include but are not limited to:
- Business promotional slogans or catchphrases:For example, the top of the website may need a frequently updated marketing slogan, or a promotional slogan for a specific holiday event. You can define a name here.
SloganThe parameter value is 'Some Enterprise, Your Trusted Partner!' - External service code: If you need to integrate some third-party statistical codes (such as Baidu Statistics, Google Analytics code snippets, but not configured in special SEO tools), customer service chat code, or specific ad placement code, and these codes are not suitable for direct embedding in template files, you can add them here.
AnalyticsCodeorCustomerServiceScriptParameter, and call its value in the template. - Collection of social media links:Although the AnQi CMS provides common social media fields in the contact information settings, if you have unconventional or need to dynamically switch social media platform links, such as a dedicated Weibo topic link for a specific event
ActivityWeiboLinkor a specific marketing page linkPromotionPageLinkor manage them here统一. - Website announcements or tips:Short announcements that need to be frequently updated but do not want to be published as articles, such as “Spring Festival Holiday Notice”, “System Maintenance Announcement”, can be defined as a
SiteAnnouncementParameter. - Feature toggle: Imagine that you might have developed a special feature module in some template, but you hope that the operations staff can flexibly turn it on or off in the backend. You can define it here.
FeatureToggleParameter, value istrueorfalseThen in the template, via{% if diy with name="FeatureToggle" %}for judgment.
How to call:Once you have added a custom parameter in the global function settings, for example, a parameter namedHelpUrlThe help page link, and you can call it in any template file by the following method:
<a href="{% diy with name="HelpUrl" %}" target="_blank">获取帮助</a>
This allows non-technical users to easily modify the global information of the website without touching the code.
2. Contact Information Settings Custom Parameters
Similar to the global function settings, in "Background Settings" -u003e "Contact Information Settings", Anqi CMS also provides default fields such as contact person, phone number, and address.If these default options are not enough to hold all your contact information, such as when you need to display a WhatsApp number, Skype ID, or a specific department's exclusive email address, you can also use the "Custom Settings Parameters" feature.
Types of custom information you can add include but are not limited to:
- More Instant Messaging Tool Accounts:For example, besides WeChat and QQ, you may also need to show
TelegramIDorLineAccount. - Contact information in different languages or regions:If your website is multilingual or targets different regions, you may want to display dedicated contact numbers or email addresses for specific languages or areas, such as
EnglishSupportEmailorJapanSalesPhone. - Customer service hours:For example, define a
CustomerServiceHoursParameters, display "Monday to Friday 9:00 - 18:00". - Store operating hours:If it is a physical store, it may be necessary
StoreOpeningHours.
How to call:Suppose you added a custom parameter named in the contact information settingsWhatsAppYou can call it like this in the template:
<p>WhatsApp: {% diy with name="WhatsApp" %}</p>
Through this method, your website operators can update this contact information at any time according to the actual situation, without modifying the template code.
Summary
{% diy %}The label is combined with the "Global Function Settings" and "Contact Information Settings" custom parameter functions in the background, which brings great flexibility to the Anqi CMS.It makes a large number of unstructured, global, or setting-specific information on websites able to be managed and accessed centrally and conveniently.This not only liberates developers, but also gives operations personnel greater autonomy, truly making website content management as free as they wish.
Common Questions (FAQ)
Q1: Why should I use{% diy %}Labels to manage custom information, rather than hardcoding them directly into the template?
A1:Use{% diy %}The biggest advantage of using labels to manage custom information isFlexibility and maintainability.When this information needs to be updated, website operators can directly modify it in the Anqi CMS backend without having to touch any code or redeploy the website.This significantly reduces operating costs and the risk of errors, especially suitable for content that requires frequent adjustments or is managed by non-technical personnel, ensuring consistency and timeliness of website information.Hard-coded information means that each modification requires technical personnel to intervene and modify the template file, which is time-consuming and prone to errors.
Q2:{% diy %}Can the label call rich text (HTML) content? If so, how can you ensure that the content is rendered correctly?
A2:Yes,{% diy %}The label can call rich text content.When you enter content containing HTML tags in the custom parameters in the background (such as text with bold, links, images, etc.), the Anqi CMS will store it as a string.|safeThe filter to ensure that HTML content is correctly parsed by the browser and not displayed as plain text. For example:{{ diy_content|safe }}This is because the default security settings of Anqi CMS will escape the output content to prevent XSS attacks.|safeThe filter explicitly tells the system that this part of the content is safe and can be output as is.
Q3: I see that custom fields can also be added in content models (such as articles, products), and these custom fields and{% diy %}what is the difference between the custom information called by tags?
A3:They are all custom information, but the service scenarios and calling methods are different.{% diy %}Labels are mainly used for callingGlobal or setting typeEnglish custom information, these information are usually related to the entire website or a specific feature area, such as the website slogan, customer service hotline, social media homepage links, etc. They are in the background "global function"