In AnQi CMS, in order to meet the needs of website customization and flexible content display, you can easily customize new parameters and call these parameters to display in the front-end template.This greatly enhances the website's customization capabilities, whether it's to display specific contact information, additional attributes of articles, or special configurations of a single page, it can handle it with ease.

AnQi CMS provides two main ways of custom parameters:Global parameters at the system/contact levelandCustom fields at the content model level. Understand these two methods and their applicable scenarios, which will help you better manage and display website content.

1. Understand the parameter customization capability of Anqi CMS.

The parameter customization capability of Anqi CMS is mainly reflected in two levels:

  1. Global and contact information parameters:These parameters are usually general information within the scope of the website, such as company name, filing number, contact phone number, etc., or some fixed text that needs to be repeated on multiple pages.They are set once in the background and can be called in any front-end template after that.
  2. Content Model Custom Field:These parameters are bound to specific content types (such as articles, products, single pages, categories, etc.)For example, you may need to add fields such as "Product Model", "Color Options", etc. to the "Product" model, and fields such as "Author Introduction", "Source Website", etc. to the "Article" model.These fields only appear when editing the corresponding content item and are called on the detail page or list of the content item.

Below, we will explain in detail how to set these parameters in the background, as well as how to call and display them in the frontend template.

Second, create custom parameters in the background.

1. Set global and contact information parameters

Global and contact information parameters are configured in the system settings in the background.

  • Path:Log in to the AnQi CMS backend, navigate to the left menu of the系统设置.

    • ForGlobal Parameters(such as website name, copyright information, custom website auxiliary links, etc.), please select全局功能设置.
    • ForContact Information Parameters(such as company fax, WhatsApp link, etc.), please select联系方式设置.
  • Operation steps:

    1. In全局功能设置or联系方式设置Page, you will see some built-in parameters. Below that, there is a自定义设置参数area.
    2. Click新增button.
    3. Enter the following information in the pop-up dialog box:
      • Parameter name:This is the name used when calling this parameter in the front-end template. It is recommended to use meaningful English words, and the system will automatically convert it to camel case (for example, if you entercompany faxThe system may process it asCompanyFaxPlease remember this name, it will be the key for your front-end calls.
      • Parameter value:Enter the actual content you want to display on the front-end. This can be text, numbers, links, or even HTML code snippets.
      • Note:Provide a brief description of the parameter function for future management and understanding.
    4. Click确定Save.

For example, if you want to display a customer service hotline in the footer but there is no such item in the built-in parameters, you can go to联系方式设置of自定义设置参数to add:

  • Parameter name: CustomerServiceHotline
  • Parameter value: 400-123-4567
  • Note: 客服热线电话

2. Set custom fields of the content model

The content model custom field allows you to add unique data fields for content types such as articles, products, etc.

  • Path:Log in to the AnQi CMS backend, navigate to the left menu of the内容管理-u003e内容模型.
  • Operation steps:
    1. Select the content model you want to add a custom field to (for example, "article model" or "product model"), click the编辑button.
    2. Scroll down to the内容模型自定义字段area.
    3. Click新增字段button.
    4. Enter the following information in the pop-up dialog box:
      • Parameter name:This is the Chinese name displayed to the editor when editing content in the background (for example, "article source").
      • Call field:This is the English variable name used when calling this field in the front-end template. Please use English lowercase letters and ensure uniqueness (for examplesourceUrl)
      • Field type:Choose the field suitable for your data type, such as单行文本(for short text)多行文本(for long text)数字/单项选择/多项选择/下拉选择etc. Different types will have different input controls when edited in the background.
      • Mandatory?:Set whether this field is required based on need.
      • Default:Set a default value for this field, which will be displayed if it is not filled in during editing.For selection type fields (radio, checkbox, dropdown), the options are entered here, one per line.
    5. Click确定Save the field.
    6. After saving, don't forget to click the bottom of the model editing page.确定Button to save all changes to the model configuration.

Now, when you add or edit articles/products under the content model, in其他参数Within the collapsed box, you will see the new custom fields added.

3. Call and display in the front-end template.

The template engine of AnQiCMS is similar to Django syntax, using{{变量}}To output variable content.

1. Call global and contact information parameters.

For global and custom parameters set in contact information, you cansystemandcontacttags to call.

  • invoke global parameters:Use{% system with name="您的参数名" %}. If you add a parameter named全局功能设置inCustomerServiceHotlineCustom parameter, you can call it like this in the template:

    <p>客服热线:{% system with name="CustomerServiceHotline" %}</p>
    

    Or, you can also assign it to a variable and use it:

    {% system hotline with name="CustomerServiceHotline" %}
    <p>客服热线:{{ hotline }}</p>
    
  • Call contact information parameter:Use{% contact with name="您的参数名" %}. If you add a parameter named联系方式设置inWhatsAppCustom parameter, you can call it like this in the template:

    <p>WhatsApp联系方式:{% contact with name="WhatsApp" %}</p>
    

    Similarly, you can also assign it to a variable:

    {% contact whatsappNum with name="WhatsApp" %}
    <p>WhatsApp联系方式:{{ whatsappNum }}</p>
    

2. Call the content model custom field

The call to the content model custom field is usually performed in the detail page templates of articles, products, categories, or single pages.

  • Invoke a single custom field:UsearchiveDetail(Article/Product),categoryDetailOr (category)pageDetail(Single page) tag and specifynamefor your调用字段.调用字段WithsourceUrlfield in the article details