In the daily operation of Anqi CMS, we often need to handle various website-level configuration information.This information may include the company's unified contact information, links related to specific business processes, or even global switches for specific features.To meet this flexible and variable demand, Anqi CMS provides the function of customizing system parameters, which allows website operators to manage and update these global settings efficiently without delving into the code.

Custom system parameters are essentially configuration items at the website level, which are unrelated to specific articles, products, or category content, but are effective for the entire website or a specific site.The advantage of this parameter lies in centralized management and quick invocation.Once defined in the background, they can be easily referenced in any template file of the website, greatly enhancing the efficiency of content updates and template maintenance.

Define Anqi CMS custom system parameters

In AnQi CMS, the definition of custom system parameters is mainly concentrated in the "Global Settings" and "Contact Information Settings" areas of the backend.

First, visit your Anq CMS backend management interface.

  1. Custom parameters in global settings.:

    • Navigate to the 'Backend Settings' under 'Global Feature Settings'.
    • In the "Custom Settings Parameters" area at the bottom of the page, you can add new parameters.
    • Each custom parameter needs to fill in three key pieces of information: 'parameter name', 'parameter value', and 'remark.'
      • Parameter NameThis is the unique identifier you use when calling this parameter in the template.Please note that the system will automatically convert the input parameter name to camel case (i.e., the first letter of each word is capitalized, and there are no spaces in between).HelpUrlUsed for template calls.
      • Parameter valueThis is the actual storage of the custom parameter and the content that will be displayed on the front end. It can be text, URL links, numbers, etc.
      • NoteThis is only used by backend administrators for parameter descriptions and identification, and will not be displayed in the front-end template.
    • Save the settings after completing the fill.
  2. Custom parameters in the contact information settings.:

    • Navigate to the "Contact Settings" under "Backend Settings".
    • Similar to the global settings, in the "Custom settings parameters" area at the bottom of the page, you can add custom parameters related to contact information.
    • Fill in the rules for "parameter nameWhatsAppThe parameter is used to store the company's WhatsApp contact information.
    • Save the settings to make the parameter effective.

In this way, you can flexibly expand the parameters provided by the system by default to meet the personalized configuration requirements.

Call the AnQi CMS custom system parameter in the template

After defining custom parameters, the next step is how to display them in the front-end template.The AnQi CMS provides dedicated tags to call these system-level parameters, the usage of which is concise and intuitive, following the Django template engine syntax rules.

  1. Call the custom parameter in the global settingsFor the custom parameters defined in the "Global Function Settings", we need to usesystemTag to call. Its basic call format is:{% system 变量名称 with name="字段名称" %}.

    • If you want to output the parameter value directly without assigning it to a variable, you can use it directly:
      
      <div>我的帮助页面链接:{% system with name="HelpUrl" %}</div>
      
    • If you want to assign a parameter value to a local variable so that it can be used multiple times in the template or for further processing, you can use:
      
      {% system helpLink with name="HelpUrl" %}
      <p>如需帮助,请访问:<a href="{{ helpLink }}">{{ helpLink }}</a></p>
      
      Remember,nameThe value must match the parameter name defined in the "Global Feature Settings" on the backend (note the case, although the backend will automatically handle camelCase naming, the template still needs to ensure accurate matching).
  2. Call the custom parameter in the contact information settings: For custom parameters defined in the "Contact Information Settings", usecontacttags to call. The basic calling format is similar tosystemLabel similar:{% contact 变量名称 with name="字段名称" %}.

    • Directly output the parameter value:
      
      <p>我们的WhatsApp联系方式是:{% contact with name="WhatsApp" %}</p>
      
    • Assign the parameter value to a local variable:
      
      {% contact whatsappNumber with name="WhatsApp" %}
      <p>加我WhatsApp:{{ whatsappNumber }}</p>
      
      Similarly,nameThe value of the attribute should match the 'parameter name' defined in the 'Contact Information Settings' on the backend.
  3. Parameter calling in multi-site environmentIn the Anqicms multi-site management supported environment, if you need to call the system parameters of other sites, you can add extra tags insystemandcontacttagsiteIdParameters to specify the site ID. For example:

    <div>其他站点的网站名称:{% system with name="SiteName" siteId="2" %}</div>
    

    This makes cross-site data calls possible.

Application scenarios and **practice

The application scenarios of customized system parameters are very extensive, for example:

  • Social media linksUnified management of social platform URLs such as Facebook, Twitter, LinkedIn, etc.
  • Customer service contact information: Besides phone and email, it can also be a Skype ID, online customer service link, etc.
  • Global notification information: For example, website maintenance announcements, festival greetings.
  • API key or third-party service link: Used as common parameters for some integration services.
  • Business-specific configurationFor example, a product display website may need a "product consultation hotline" parameter.

The practices of using custom parameters include:

  • Keep the naming clear.Parameter names should be descriptive, allowing one to understand their purpose at a glance.
  • Differentiate the scopePlace global website settings in "Global Settings" and those strongly related to contact information in "Contact Settings".
  • Avoid overuseFor properties unique to content models (articles, products), you should manage them through custom fields of the content model, rather than abuse system parameters.The system parameters are more suitable for those that span the entire website's general configuration.
  • Update notes in a timely manner: Add detailed remarks for each custom parameter to facilitate understanding and maintenance by team members.

The Anqi CMS custom system parameter function provides a powerful and flexible tool for website operators.It not only simplifies the management of website configuration, but also brings higher freedom and efficiency to template development.By reasonably defining and calling these parameters, we can build more maintainable, responsive dynamic websites.

Frequently Asked Questions (FAQ)

1. What types of information are most suitable as custom system parameters for Anqi CMS?

Custom system parameters are most suitable for storing information that is universally applicable to the entire website or a specific site and does not change with specific content (such as articles or products).This includes but is not limited to: website name, logo image path, filing number, copyright information, social media homepage links, unified customer service phone or email, API key, external script code snippets, or any global text or link that needs to be displayed uniformly across multiple pages and is easy to modify.

2. How to ensure that the parameter name is correctly recognized when calling custom parameters in a template?

When defining custom parameters in the AnQi CMS backend, the "parameter name" you enter will be automatically converted to camel case.For example, if you enter 'Help Url', it may display as 'HelpUrl' in the background.nameThe value of the property. For example, usingname="HelpUrl"instead ofname="Help_Url"orname="helpurl"Make sure that the naming in the template matches the camel case naming generated by the background, otherwise it cannot be successfully called.

3. Can I use custom system parameters to store specific attributes of articles or products, such as the author of an article or the price of a product?

Do not do this.Custom system parameters are mainly used for general configuration at the website level.For articles, products, or other content models with unique properties, AnQi CMS provides the 'Content Model' custom field feature.You can define these fields in the corresponding 'content model' (for example, add an 'author' field to the article model, add a 'price' field to the product model), which can organize data more reasonably and support batch management and filtering of content.Mixing specific data into system parameters will make management chaotic and difficult to maintain.