As an experienced website operations expert, I am well aware that it is crucial to manage and call various content flexibly in daily work.AnQiCMS (AnQiCMS) performs very well in this aspect, it provides a series of powerful tags that make content operation effortless.Today, let's delve deeper into the types of "custom content information" you can create in the background as an AnQi CMS user, and through{% diy %}Tags can be flexibly called on the front end of the website.
{% diy %}Labels, as the name implies, is the abbreviation of "Do It Yourself", it plays the role of a universal tool in Anqi CMS, allowing you to manage and call information that does not belong to the regular content system of articles, products, categories, etc., but needs to be repeated at multiple places on the website.This greatly enhances the maintainability and operational efficiency of the website, avoiding the update difficulties brought by hardcoding data in templates.
{% diy %}The custom information sources that the tag can call.
The backend design of Anqi CMS is very user-friendly, allowing you to create available in two main areas.{% diy %}Custom parameter for tag call:
- Custom parameter in global function settings
- Custom parameters in the contact information settings.
Let's unfold one by one.
1. Custom parameter in global function settings
In the AnQi CMS backend, you can navigate to "Backend Settings" -> "Global Function Settings" to find this area.The 'Custom settings parameters' section opens up a whole new dimension of content management.When the built-in system settings of AnQi CMS (such as website name, Logo, filing number, etc.) cannot meet the specific needs of your website, you can add it yourself here.
You can add custom information types including but not limited to:
- Business slogan or catchphrase:For example, the top of the website may need a frequently updated marketing slogan, or a promotional slogan for a specific festival event. You can define a name for it here.
SloganThe parameter, with the value of 'Some Company, your trusted partner!' - External service code: If you need to integrate some third-party statistical code (such as Baidu Statistics, Google Analytics code snippet, but not configured in special SEO tools), customer service chat code, or specific ad placement code, and these codes are not suitable to be directly embedded in template files, you can add them here
AnalyticsCodeorCustomerServiceScriptParameter, and call its value in the template. - Collection of social media links:Although Anqicms in the contact information settings provides common social media fields, but if you have irregular or need to dynamically switch social media platform links, such as a special microblog topic link for an event
ActivityWeiboLinkOr a promotional link on a specific marketing pagePromotionPageLinkOr you can manage it here - Website announcement or prompt information: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 Notice", can be defined as one.
SiteAnnouncementParameter. - Toggle for special features:Imagine that you may have developed a special feature module in some template, but you want the operations personnel to be able to turn it on or off flexibly in the background. You can define one here
FeatureToggleParameter, is set totrueorfalseThen pass through the template{% if diy with name="FeatureToggle" %}to judge.
How to call:Once you have added a custom parameter in the global feature settings, for example, a parameter namedHelpUrlThe help page link, you can call it in any template file in the following way:
<a href="{% diy with name="HelpUrl" %}" target="_blank">获取帮助</a>
This allows non-technical personnel to easily modify the global information of the website without touching the code.
2. Custom parameters in contact information settings
Similar to the global function settings, in the "Background Settings" -> "Contact Information Settings", AnQi CMS also provides default fields such as contact person, phone number, address, and so on.But if these default items are not enough to carry all your contact information, such as when you need to display a WhatsApp number, Skype ID, or a dedicated email for a specific department, you can also use the "Custom Setting Parameter" feature.
You can add custom information types including but not limited to:
- More instant messaging tool accounts:For example, in addition to WeChat and QQ, you may also need to display
TelegramIDorLineAccount. - Contact information in different languages or regions:If your website is multilingual or targets different regions, you may want to display exclusive contact numbers or email addresses for specific languages or areas, such as
EnglishSupportEmailorJapanSalesPhone. - Service hours:For example, define a
CustomerServiceHoursParameters, display “Monday to Friday 9:00 - 18:00”. - Store business hours:If it is a physical store, it may be needed
StoreOpeningHours.
How to call:Assume you added a custom parameter namedWhatsAppin the contact information settings, you can call it like this:
<p>WhatsApp: {% diy with name="WhatsApp" %}</p>
In this way, 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配合background's "Global Function Settings" and "Contact Information Settings" custom parameter function, brings great flexibility to Anqi CMS.It allows for the centralized and convenient management and invocation of much non-structured, global, or setting-specific information on websites.This not only liberates developers, but also gives operation personnel greater autonomy, allowing website content management to truly achieve 'do as one wishes'.
Frequently Asked 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 greatest advantage of using labels to manage custom information lies inFlexibility and maintainability. When this information needs to be updated, website operators can directly modify it in the Anq CMS backend without touching any code or redeploying the website.This greatly reduces the operating costs and risk of errors, especially suitable for those who need to adjust frequently or by non-technical personnel responsible for updates, ensuring the consistency and timeliness of website information.Hardcoded 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 a tag call rich text (HTML) content? If so, how can you ensure that the content is rendered correctly?
A2:Yes,{% diy %}Tags can call rich text content. When you enter content containing HTML tags in the custom parameters in the background (for example, text with bold, links, images, etc.), Anqi CMS will store it as a string.When calling such custom parameters in the template, you need to use|safeA 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 AnQi CMS defaults to escaping output content to prevent XSS attacks,|safeThe filter explicitly informs 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 the difference between these custom fields and{% diy %}the custom information called by tags is?
A3:They are all custom information, but the service scenarios and calling methods are different.{% diy %}Tags are mainly used for callingGlobal or setting classCustom information, which is usually related to the entire website or a specific functional area, such as the website slogan, customer service hotline, social media homepage link, etc. They are in the background "Global Function"