In AnQi CMS, to meet the personalized and flexible content display needs of the website, 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 for displaying specific contact information, additional attributes of articles, or special configurations for a single page, it can handle it with ease.
AnQiCMS provides two main ways of setting up custom parameters:System/Contact level global parametersandCustom fields at the content model levelUnderstanding these two methods and their applicable scenarios will help you better manage and display website content.
One, Understand the parameter customization capability of AnQi CMS
The parameter customization capability of AnQi CMS is mainly reflected in two levels:
- 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 reused on multiple pages.They are set up once in the background and can be called in any frontend template.
- Custom fields of content model: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' to the 'Product' model, and fields such as 'Author Introduction', 'Source Website' to the 'Article' model.These fields only appear when editing the corresponding content items and are called on the detail page or list of the content item.
Below, we will detail how to set these parameters in the background, as well as how to call and display them in the front-end 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
系统设置.- 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
联系方式设置.
- ForGlobal Parameters(such as website name, copyright information, custom website auxiliary links, etc.), please select
Operation Steps:
- In
全局功能设置or联系方式设置Page, you will see some built-in parameters. Below them, there is a自定义设置参数area. - Click
新增button. - In the pop-up dialog box, fill in the following information:
- Parameter name:This is the name used when calling this parameter in the front-end template. It is recommended to use meaningful English words, as the system will automatically convert it to camel case (for example, if you enter
company fax,The system may process it asCompanyFax)。Please remember this name, it will be the key for your frontend call. - Parameter value:Fill in 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 function of this parameter for future management and understanding.
- Parameter name:This is the name used when calling this parameter in the front-end template. It is recommended to use meaningful English words, as the system will automatically convert it to camel case (for example, if you enter
- Click
确定Save.
- In
For example, if you want to display a customer service hotline in the footer but this item is not available in the built-in parameters, you can go to联系方式设置of自定义设置参数Add in
- Parameter name:
CustomerServiceHotline - Parameter value:
400-123-4567 - Note:
客服热线电话
2. Set custom fields of content model
The content model custom field allows you to add unique data fields to content types such as articles, products, etc.
- Path:Log in to the Anqi CMS backend, navigate to the left menu of
内容管理-内容模型. - Operation Steps:
- Select the content model you want to add custom fields to (for example, "Article Model" or "Product Model"), click the
编辑button. - After entering the model editing page, scroll down to
内容模型自定义字段area. - Click
新增字段button. - In the pop-up dialog box, fill in the following information:
- Parameter name:This is the Chinese name displayed to the editor when editing content in the background (for example, "Source of the article").
- Field call:This is the English variable name used when calling this field in the front-end template. Make sure to use lowercase English letters and maintain uniqueness (for example)
sourceUrl). - Field Type:Choose the field suitable for your data type,
单行文本(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 according to your needs.
- Default value:Set a default value for this field. If not filled in during editing, this default value will be displayed.For fields of selection type (radio, checkbox, dropdown), enter the options here, one per line.
- Click
确定Save the field. - After saving, don't forget to click the
确定button at the bottom of the model editing page to save the entire configuration changes of the model.
- Select the content model you want to add custom fields to (for example, "Article Model" or "Product Model"), click the
Now, when you add or edit articles/products under this content model,其他参数[en]Within the collapse box, you will see the new custom fields added.
[en]3. Call and display in the front-end template.
[en]The template engine of Anqi CMS is similar to Django syntax, using{{变量}}Output the variable content.
1. Call global and contact information parameters.
Custom parameters set in global and contact information can be accessed by.systemandcontacttags to call.
Call global parameters:Use
{% system with name="您的参数名" %}If you add a custom parameter named全局功能设置in the middleCustomerServiceHotlineYou can call it in the template like this:<p>客服热线:{% system with name="CustomerServiceHotline" %}</p>Alternatively, you can also assign it to a variable and use it:
{% system hotline with name="CustomerServiceHotline" %} <p>客服热线:{{ hotline }}</p>Call contact information parameters:Use
{% contact with name="您的参数名" %}If you add a custom parameter named联系方式设置in the middleWhatsAppYou can call it in the template like this:<p>WhatsApp联系方式:{% contact with name="WhatsApp" %}</p>Similarly, it can also be assigned to a variable:
{% contact whatsappNum with name="WhatsApp" %} <p>WhatsApp联系方式:{{ whatsappNum }}</p>
2. Call content model custom fields
The invocation of custom fields in content models usually occurs in detail page templates for articles, products, categories, or single pages.
- Invoke a single custom field:Use
archiveDetail(Article/Product),categoryDetail(Category) orpageDetail[en] Single-page label, and specifynamefor you调用字段.调用字段response forsourceUrlIf you add a field with the name in the article model,