When building and operating a website, we often need to display more information than just the title and content, such as product models, colors, inventory, or the author, source, and publishing platform of the article.AnQiCMS understands the importance of personalized content display and therefore provides a highly flexible custom parameter field function, making website content management and front-end presentation both powerful and convenient.Next, let's delve deeper into how to make full use of this feature in AnQiCMS, bringing dynamic content to your website.

Step 1: Define your content structure - Custom parameter field creation

In AnQiCMS, all content is organized based on the 'content model'.Whether it is an article, product, or other custom type, you can tailor a unique field structure for it.This is like building a dedicated 'skeleton' for your content, ensuring that each type of content can carry its unique information.

To create or modify custom parameter fields, you need to go to the 'Content Management' section of the AnQiCMS backend and find the 'Content Model'.Here, the default models such as 'article model' and 'product model' are provided, and you can also add custom models according to your business needs.

Select a content model to enter the editing interface, where you will see an area named 'Content Model Custom Fields'.In here, you can click "Add Field" to add new custom parameters to the model.During the addition process, several key pieces of information need to be clarified:

  • Parameter name:This is the name of this custom field displayed to the administrator in the backend management interface, for example, "Product Model", "Author Name", "Stock Quantity".It should be intuitive and easy to understand.
  • Call field:This is the field name that will be used when calling this parameter in the front-end template, it must be alphabetic, and it is recommended to use camel case (such asproductModel/authorName/stockQuantity). In the subsequent template development, we will mainly obtain data through this "call field".
  • Field type:AnQiCMS supports various field types to accommodate different data entry needs, for example:
    • Single-line text:Suitable for brief text information, such as model and brand.
    • Number:Ensure only numbers can be entered, suitable for prices, inventory, etc.
    • Multi-line text:Suitable for longer descriptions, such as product features, author bios.
    • Single choice, multiple choice, dropdown choice:These selection fields are very suitable for preset options, such as colors (red, blue, green), sizes (S, M, L), and regions, which greatly improve the standardization and accuracy of data entry.You can set these options one per line in the "Default".
  • Mandatory?:Based on the importance of the field, you can choose whether it should be a required field when publishing content.
  • Default:Set a default value for the field, which can be automatically filled in when publishing content to reduce manual input.

After completing these settings, save your content model. Now, you have successfully defined a new data structure for your content type.

Second step: Fill in your data - add custom information to the article or product

With a customized field structure, the next step is to enter the data for the actual article or product.When you go to the 'Content Management' under 'Publish Document' or edit an existing document, you will find a collapsible box for 'Other Parameters' at the bottom of the page.

Expand this collapse box, and you will see those custom fields that were just defined in the content model, clearly arranged according to the 'parameter name' you set.You can easily fill in unique property values for each piece of content, whether it is inputting text, selecting numbers, or making a selection in a dropdown menu, it is very intuitive.

If some fields are left blank, and you have set a default value for them in the content model, then when displayed on the front end, the system will automatically assign the default value to the field.For functions such as images contained in article content or automatically extracting summaries, AnQiCMS will also intelligently process them to save you time.

Third step: Dynamically display content - call custom parameters in the front-end template

The data entry is complete, the most exciting part is how to dynamically display this custom information on the website front-end.AnQiCMS uses Django template engine syntax, with its concise and powerful tag and variable calling methods, making this process efficient and flexible.

Display custom parameters in the template, mainly the following common methods:

1. Directly call specific custom fields in the detail page

If you are on the article or product detail page (usuallydetail.htmlor{模型table}/detail.htmlIn it, you can directly display a specific custom parameter, such as the "author" of an article or the "model" of a product.archiveAccess the properties of an object:

`twig {# Assume the custom field "author" is called author #}