Flexible content model: the cornerstone of AnQi CMS customization
The 'flexible content model' feature is instrumental in meeting diverse content needs of Anqi CMS.The system preset "Article Model" and "Product Model" and other basic models, but the real strength lies in that it allows us to create or modify exclusive content models for different types of content.Every content model is like a blueprint for content, defining what information the class of content should include, such as an article may need 'author', 'source', while a product may need 'brand', 'price', and so on.This specific model-related additional information is achieved through custom fields in the content model.
In the content model, define custom fields
To add custom fields to the document editing page, first you need to configure these fields in the Anqi CMS backend management interface.This is usually completed by navigating to the "Content Management" section under "Content Model".Here, we can choose to edit the existing content model, or create a brand new one.
After entering the editing interface of a specific content model, you will see a section named "Content Model Custom Fields".Here is the place where we define various personalized content properties.
- Parameter name (Chinese name): This is the friendly name displayed on the back-end interface for operators, such as "Article Author
- Field call (English name)This is the actual name stored in the database, as well as the identifier used when calling this field in the frontend template. It must use English letters, for example
author/brand. - field type: English provided by 安企CMS to accommodate various data input requirements, including:
- Single Line Text: Suitable for brief text input, such as titles, short links, etc.
- Number: Only numeric input is allowed, suitable for prices, inventory quantities, etc.
- Multi-line text: Suitable for longer text input, such as product descriptions, detailed explanations, etc.
- Single selection: Allow preset multiple options, but only one can be selected, suitable for gender, status, etc.
- Multiple selection: Allow preset multiple options and select multiple items as needed. Suitable for multi-label, multi-functional selection, etc.
- Drop-down selection: Provide a dropdown menu where users can select an option from predefined choices. The function is similar to a single selection, but it differs in the way it is presented on the interface.
- Is required: You can choose whether this field must be filled in when the document is published.
- Default value: If the field needs to preset a value, you can fill it in here.For single-choice, multiple-choice, and dropdown selection fields, the default values here define the specific option content, with each option taking up a line.
After defining and saving the custom fields through the above steps, these fields are successfully attached to the corresponding content model.
Custom field display on the document editing page
Once custom fields are defined in the content model, they seamlessly integrate into the document editing page associated with the model.When we select a specific category and start creating or editing a document, if the content model associated with that category contains custom fields, these fields will automatically appear in the 'Other Parameters' collapsible area of the document editing interface.
This means that whether it is to add an 'Editor-in-Chief' field to an article or to add a 'Material' option to a product, operations personnel can conveniently find and fill in these customized information on the same document editing page.This design greatly simplifies the content creation and management process, ensuring the completeness and consistency of the information required for different types of content.
Invoke custom fields in the front-end template
The value of custom fields is not only reflected in the background data management, but also in their ability to flexibly present on the website's front-end page.The autoCMS provides powerful template tags, allowing us to easily display custom field content to users.
The most common way is toarchiveDetailLabel directly calls the value of a specific custom field. For example, if we define a field namedauthorin the content model, we can use it in the template on the document detail page.{% archiveDetail with name="author" %}Show author information.
For scenarios that require iterating over all custom fields, such as displaying a product's detailed parameter list, you can usearchiveParamsLabel. This label will return an array object containing all custom field names and values, and we can iterate over it.forTags) to dynamically display these parameters, greatly enhancing the flexibility and maintainability of the template.
Through this method, we can ensure that the presentation form of the website content is highly consistent with the backend management structure, achieving truly personalized content display.
The Anqi CMS provides powerful content management tools for website operators through its highly flexible content model and intuitive custom field configuration.It not only makes content creation more refined, but also enables website content to better respond to reader needs, ultimately attracting and retaining users through high-quality, personalized content.
Frequently Asked Questions (FAQs)
问:我可以在创建自定义字段后更改其类型吗?答:The CMS allows you to modify the type of custom fields, but please operate with caution.Changing the field type may cause existing data to be lost or incompatible in format.For example, changing a field containing text to a "number" type may cause the existing text data to be incorrectly converted and displayed.Therefore, it is recommended to plan ahead when defining field types to avoid unnecessary modifications later.
问:如果我删除了一个包含自定义字段的内容模型,会发生什么?答:When you delete a content model, the system will prompt you that all documents and categories under this model will also be deleted.This means that all custom field data associated with these documents will also be cleared.Before performing this operation, please ensure that you have backed up the data and confirmed that the deletion operation will not cause irreversible effects on the website content.
问:Custom field supports multilingual?答:The custom field itself stores content in a single language.If you need to provide different custom field content for different language versions, the usual practice is to create independent documents for each language site in the multi-site management feature of Safe CMS, and fill in the corresponding language custom field content in these documents.Although the field itself does not provide built-in multi-language translation functionality, multi-language content management can be achieved through site separation.