In website operation, we often encounter situations where we need to quickly adjust certain information, such as updating the link of the help page, changing the status of a certain feature switch, or displaying some custom text that is not often changed but needs to be flexible to modify.If each modification requires delving into the code file, it would undoubtedly greatly reduce efficiency.

AnQiCMS (AnQiCMS) is well aware of this pain point and therefore provides a very convenient custom setting mechanism, allowing you to easily configure any content in the background without writing any code, and present it in the website template.

Background settings: Configure your custom content

To implement this feature, we first need to make simple configurations in the backend of the Anqi CMS.This usually involves the 'Global Function Settings' section in the 'Background Settings'.Here, you can find an area named "Custom Setting Parameters".

The link to our help page displayed in the website footer may be updated from time to time. We can add a custom parameter here:

  • Parameter Name:HelpUrl(Suggest using camel case naming, pure English letters, which will be more standardized and convenient when called in the template)
  • 参数值 (Parameter Value):https://www.yourdomain.com/help(Enter the actual URL of your help page)
  • Remark:网站帮助页面的链接(Used to describe the purpose of the parameter, convenient for you and other operators to understand)

The parameter name is the unique identifier you use when calling the template, and it is recommended to use clear and meaningful English letters.The parameter value is the specific content you want to display.The remark field is used for internal management, helping you and other operators to understand the purpose of this parameter.

Template call: Display custom content on the website

Custom parameters are configured in the background, and the next step is to integrate them into the front-end template of the website. The Anqi CMS provides powerful template tag features, especiallysystemTags, it is the core to obtain the global configuration information of the website.

systemTags are mainly used to retrieve various parameters configured in the "Global Function Settings" of the backend, including website name, website logo, filing number, as well as our customized parameters.

To call the setting we just madeHelpUrl, you can use the following method in the template file (for examplefooter.htmlorheader.html):

<a href="{% system with name="HelpUrl" %}" target="_blank">帮助中心</a>

This code will directly output the valueHelpUrlthat has been set on the back end, and use it as a hyperlink<a>Tagshrefproperties.

If you want to store this value in a variable first, so that it can be used multiple times in a template or for other logical judgments, you can operate as follows:

{% system helpPageUrl with name="HelpUrl" %}
<a href="{{ helpPageUrl }}" target="_blank">帮助中心</a>
<p>更多信息请访问:{{ helpPageUrl }}</p>

Here, we first assignHelpUrlis assigned tohelpPageUrlThis variable, and then it can be freely referenced in the template. This method improves the readability and maintainability of the code, and avoids repeated calls to the tag.

超越链接:更多自定义内容的运用

The power of customizing settings parameters is not limited to this. In addition to simple URLs, you can also store various types of content, such as:

  • Website announcement text:Configure a brief announcement in the background, such as "Notice of shipment suspension during the National Day holiday", which is displayed at the top navigation by the front-end.
  • Website statistics code snippet:For some public, non-sensitive third-party integration codes (such as website statistics IDs), they can be flexibly managed through custom parameters, which is convenient for replacement.
  • Feature switch:Configure a boolean value (such asIsNewFeatureEnabledwith a value oftrueorfalse), and display a new feature module or ad space in the template via the{% if %}tag. The contact phone number or address for different regions:
  • If your website serves multiple regions, you can set different contact methods for each region through custom parameters, and display them in the template through logical judgment.

CombinecontactLabel (specifically used for contact information) anddiyLabels (used for more general custom content), Anqi CMS provides you with great content operation flexibility, allowing you to easily meet various content display needs.

Tips and precautions

  • Naming conventions:Choose clear, consistent English names for custom parameters for easy management and search in the future. Avoid using too generic or names that may conflict with system built-in parameters.
  • moderate use:Avoid storing large, frequently changing, or complexly structured data as custom parameters; these are better managed through content models or data lists to maintain structured and maintainable data.
  • Test verification:After each modification of custom parameters, be sure to clear the website cache and visit the front desk page to confirm that the content is displayed correctly. If the content contains HTML code, it may be necessary to use|safeThe filter ensures that it is parsed correctly and not escaped.

Through the custom settings and template tags provided by the Aanqi CMS, you can easily display any content configured on the backend on the website front end, greatly enhancing the efficiency and flexibility of website operation.Whether it is a simple URL update or a complex text display, it can be completed without touching the code, making content management more intuitive.


Common Questions (FAQ)

  1. Can I directly input HTML code in the custom parameters? If so, how can I ensure it is displayed correctly on the front end?Can.You can enter HTML code in the 'Parameter Value' of the custom parameter.|safefilter. For example:<div>{% system myHtmlContent with name="MyHtmlContent" %}{{ myHtmlContent|safe }}</div>Please note, using|safeMeans that you trust the safety of these HTML contents, avoiding XSS risk.

  2. I set up a custom parameter and referred to it in the template, but why is the front-end page not displaying or displaying incorrectly?Firstly, please check if the 'parameter name' of the custom parameters matches the one in the templatenameThe value of the property is completely consistent (including case).其次,modify the background settings after, you may need to clear the website cache to make the changes take effect.You can try to clean up in the "Update Cache" feature on the background management interface.If the issue still exists, please check if your template file has been saved and uploaded correctly.

  3. What is the difference between custom parameters and content models (such as article, product models), and how should I choose?Custom parameters are more suitable for storing small, global, or cross-page reusable, and relatively simple single-value content, such as help page URLs, some text in the company profile, website announcements, etc.They usually do not have complex structures and a large number of fields.While the content model is used to manage a large amount of structured, multi-field content, such as articles, products, case studies, etc., these contents usually have complex attributes such as categories, tags, images, detailed content, and require functions such as list display, detail page display, and search.In simple terms, custom parameters are 'small and clever' global configurations, and the content model is 'large and comprehensive' data management.