How to obtain the background custom global parameters in the template?

Calendar 👁️ 69

In Anqi CMS, the flexibility and maintainability of the website are one of its core advantages.Content operators and developers often need to dynamically adjust some global information of the website without modifying the template code, such as the company name, contact number, and even some marketing campaign links.These are the background-defined global parameters that are the key to realizing this requirement.

Today, let's take a deep dive into how to easily obtain and display these custom global parameters configured in the Anqi CMS template.

Why do we need global parameters?

Imagine if your website needs to change the company name or phone number, and this information is hard-coded in dozens of template files, then each modification will be a time-consuming and error-prone task.The appearance of global parameters is to solve such problems.It allows you to manage these common information in the website background uniformly, when the information changes, you only need to modify it once in the background, and all pages that call this parameter will automatically update, greatly improving the operation efficiency and maintainability of the website.

How to set global parameters on the back end?

AnQi CMS provides several places for you to set global parameters, the most commonly used ones are the 'Global Function Settings' under 'Background Settings' and 'Contact Information Settings'.

  1. Global feature settingsIn the "background settings" -> "global function settings", in addition to the system built-in parameters such as website name, website logo, filing number, etc., you can also add more exclusive global parameters through "custom parameter settings".

    • Click "Add Parameter", enter the "Parameter Name" (this is the unique identifier used when calling the template, it is recommended to use English, which will be automatically converted to camel case by the system), enter the "Parameter Value" (the content you want to display), and add a "Remark" for future management. For example, you can add a namedHelpUrlThe parameter value,https://en.anqicms.com/help.
  2. Contact information settingsSimilarly, the "Background Settings" -> "Contact Information Settings" also supports custom parameters. It is usually used to manage phone numbers, email addresses, WeChat, and other contact information.

    • You can add such asWhatsAppcustom parameters and enter your WhatsApp contact number.

These settings are completed, these custom parameters are the same as the built-in system parameters and can be flexibly called in the front-end template.

Get global parameters in the template.

The AnQi CMS template engine supports tag syntax similar to Django, you can use specific tags to retrieve global parameters set in the background. The core tags mainly includesystem/contactanddiy.

1. Obtain system-level global parameters (systemtags)

systemThe tag is specifically used to obtain parameters configured in the "Global Function Settings", whether built-in or custom.

Basic usage: {% system 变量名称 with name="字段名称" %}

here,字段名称It is the parameter name set in the background.

  • Directly output the built-in parameters:If you want to display the filing number at the bottom of the page, you can write it like this directly:

    <p><a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a></p>
    

    here,SiteIcpIs an AnQi CMS built-in record number parameter name.

  • Output a custom parameter and assign it to a variable:Assuming you have defined a named in the background global settings.HelpUrlThe custom parameter, you can retrieve and use it in the template like this:

    {% system helpPageUrl with name="HelpUrl" %}
    <a href="{{ helpPageUrl }}">查看帮助文档</a>
    

    BywithThe keyword, you can assign the value of the parameter you get tohelpPageUrlthis variable and then use it multiple times in the template.

  • Get the current year:Furthermore,systemThe tag also has an auxiliary function, which is to get the current year, and this is very useful in copyright information:

    <p>&copy; {% now "2006" %} {{ siteName }}. All Rights Reserved.</p>
    

    Here{% now "2006" %}It will display the current year.

2. Retrieve contact information global parameters (contacttags)

contactTag used to retrieve parameters configured in the "Contact Information Settings", including built-in contact methods and custom parameters you define.

Basic usage: {% contact 变量名称 with name="字段名称" %}

  • Directly output the built-in contact phone number:

    <span>联系电话:{% contact with name="Cellphone" %}</span>
    

    here,CellphoneIt is the built-in contact phone parameter name of AnQi CMS.

  • Output the custom WhatsApp parameter:Assuming you added a namedWhatsAppcustom parameter named:

    {% contact whatsappNumber with name="WhatsApp" %}
    <a href="https://wa.me/{{ whatsappNumber }}" target="_blank">通过WhatsApp联系我们</a>
    

3. Obtain general custom content(diytags)

exceptsystemandcontacttags, Anqi CMS also provides a more generaldiyThe label is used to retrieve custom content information that may be defined at other locations in the background. Although the document does not directly provide background settingsdiyThe entry of the parameter, but if your system has been developed twice or there are additional global parameters defined in some content modelsdiyThe label will be your good helper.

Basic usage: {% diy 变量名称 with name="字段名称" %}

  • Output general custom parameters:Suppose you have a variable namedAuthorCustom global parameters, you can use:diytags:
    
    {% diy websiteAuthor with name="Author" %}
    <span>网站作者:{{ websiteAuthor }}</span>
    

Practical tips and注意事项

  • Case sensitivity of parameter names:When defining parameter names in the background, although it is recommended to use English, there is no need to worry about case, AnQi CMS will automatically match during template calls.
  • Multi-site support:If you have used the multi-site feature of Anqi CMS and want to call the global parameters of a specific site, you cansystem/contact/diyadd in thesiteIdparameters, for example{% system with name="SiteName" siteId="2" %}of which"2"which is the ID of the target site.
  • HTML content processing:If your custom parameter value contains HTML code (such as copyright information output by a rich text editor), be sure to use it when outputting in the template:|safeA filter to prevent HTML from being escaped and unable to display normally.
    
    {% system siteCopyright with name="SiteCopyright" %}
    <div>{{ siteCopyright|safe }}</div>
    

By using these flexible global parameter calling methods, you can make your Anqi CMS website template more dynamic and easy to manage, thereby more efficiently carrying out content updates and website operations.

Frequently Asked Questions (FAQ)

  1. Ask: How should I properly display if my custom parameters contain HTML code? Answer:When your custom parameter value is in HTML format, it needs to be used when outputting in the template|safeFilter. For example, if you define a "website introduction" parameter that contains HTML in the backgroundSiteIntro, it should be written like this in the template:{% system siteIntroContent with name="SiteIntro" %}{{ siteIntroContent|safe }}. So that the HTML code will be parsed and displayed correctly by the browser.

  2. Question: Why did I set custom parameters in the background, but there is no content displayed when called in the template? Answer:This usually has several reasons. First, please check if thenameThe attribute value matches completely. Next, confirm whether you have added the parameter in the correct background setting area (such as "Global Function Settings" or "Contact Information Settings") and used the corresponding template tag (systemorcontact)。Finally, if it is in a multi-site environment, confirm whether the correctsiteIdSometimes, clearing the system cache (found in the background menu under the 'Update Cache' option) may also resolve display issues.

  3. Ask: How to call global parameters of other sites in a multi-site environment? Answer: ":In the multi-site environment of AnQi CMS, you can call in the following way:system/contactanddiythe tag withsiteIdParameters to specify the global parameters to be called for which site. For example, if you want to get the site with ID2write the site name like this:{% system otherSiteName with name="SiteName" siteId="2" %}This allows cross-site invocation of global parameters.

Related articles

How to customize or override the JSON-LD structured data in AnQi CMS?

The AnQi CMS has always been committed to providing efficient and flexible solutions in content operation and search engine optimization.Structured data, especially JSON-LD, is an important means to improve the visibility of website content in search engines.It can help search engines understand the page content more accurately, thereby giving it the opportunity to display richer search results (i.e., rich media summaries) and attract more users to click. AnQi CMS understands the importance of structured data, and has preset some default JSON-LD structured data for you in the system design.

2025-11-08

How to display the Banner slideshow image on the homepage or a specific group?

The homepage and banner carousel images of specific groups, which are key elements in attracting visitors and displaying core content on the website.A convenient and flexible system for management and display, which can greatly improve the operation of your website.AnQiCMS (AnQiCMS) takes advantage of its intuitive design and powerful template tag features, allowing you to effortlessly handle these visual elements, whether it's creating an eye-catching homepage image or customizing exclusive promotional images for specific category pages, you can do so with ease.

2025-11-08

How to implement language switching functionality for multilingual sites in Anqi CMS?

When our website is aimed at serving global customers, providing multilingual support has become an indispensable feature.This can not only help us expand the international market, but also significantly improve the access experience of users in different languages.AnQiCMS (AnQiCMS) fully understands this need, therefore, it has made multilingual support one of its core highlights, allowing us to easily build multilingual websites and switch languages.How to implement language switching for multi-language sites in AnQi CMS

2025-11-08

How to create pagination navigation for document lists, Tag lists, and other Anqi CMS features?

In website operation, providing clear and easy-to-use pagination navigation for content lists not only greatly improves user experience but also optimizes search engine crawling efficiency, helping content to be discovered better.AnQiCMS (AnQiCMS) knows this and therefore provides powerful and flexible pagination tags in template design, allowing content operators to easily create pagination navigation for document lists, tag lists, and so on. We will discuss together how to implement this feature in AnQi CMS templates, organizing your website content neatly.--- ###

2025-11-08

How to display the current year or a specified format of time in the template?

In website operation, it is often necessary to keep the web page content up-to-date or accurately display the time of specific events, whether it is the copyright year in the footer, the publication date of the article, or the update time of the product. These dynamic time information can make the website look more professional and active.AnQiCMS provides a very flexible and intuitive way, allowing you to easily display the current year or specify the format of time in templates. Next, we will explore two main methods together, allowing your AnQiCMS website to flexibly display various time information.## One

2025-11-08

How to customize URL rewrite rules in AnQi CMS to optimize SEO?

In website operation, the website structure is not just a string of characters for accessing pages, but also a key factor in the website's performance in search engines.A clear, meaningful, and search engine-friendly URL (Uniform Resource Locator) that can significantly improve the SEO effect of the website, helping the content to be discovered and understood more easily.AnQiCMS (AnQiCMS) knows this and therefore integrated powerful pseudo-static and URL customization features into the system design from the beginning, allowing website operators to flexibly configure URL rules to meet different SEO strategy needs.

2025-11-08

How to set custom URL aliases for articles, categories, and single pages?

On the day when content management is increasingly important, a clear and friendly URL address can not only help search engines better understand the content of the page, improve the SEO performance of the website, but also provide users with a better browsing experience, and even help in brand promotion.AnQiCMS understands this and provides a powerful and flexible custom URL alias feature, allowing you to easily set personalized addresses for articles, categories, single pages, and even tags on your website.Next, we will explore how to finely manage these URL aliases in AnQiCMS.### Core Premise

2025-11-08

How to convert string case or capitalize the first letter in SafeCMS?

In website content operation, the way text is presented often affects the user's reading experience and brand image.In order to unify brand style, improve the readability of the title, or highlight text in specific scenarios, it is a common requirement to convert strings to uppercase or capitalize the first letter.AnQiCMS (AnQiCMS) with its flexible Django template engine syntax, provides us with several concise and efficient methods for handling these string formatting tasks.These operations do not require complex backend code modifications, just apply the corresponding filters in the template file, and you can easily achieve it

2025-11-08