As a deep user of Anqi CMS as a website operator, I know that the flexibility of the content model is one of its core advantages.AnQi CMS not only provides an efficient content management framework, but also enables us to easily expand and customize the content structure according to specific business needs, thereby realizing personalized content input and management on the document editing page.
Flexible content model: the foundation of AnQiCMS customization
The flexible content model feature of AnQi CMS is instrumental in meeting diverse content needs.The system has preset basic models such as 'Article Model' and 'Product Model', but its real strength lies in the fact that it allows us to create or modify exclusive content models for different types of content.Each content model is like a blueprint for content, defining what information this type of content should include, such as an article may need "author", "source", and a product may need "brand", "price", and so on.This additional information specific to the model is implemented through custom fields in the content model.
Define custom fields in the content model
To add a custom field to the document editing page, you first need to configure these fields in the Anqi CMS backend management interface.This is usually done 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 an area named "Content Model Custom Fields".This is where we define various personalized content attributes.When adding custom fields, it is necessary to clarify several key pieces of information:
- Parameter name (Chinese name)This is the friendly name displayed on the background interface for operation personnel, for example, 'article author', 'product brand', etc.
- Field call (English name)This is the actual name of the field stored in the database, as well as the identifier used when calling the field in the frontend template. It must use letters, such as
author/brand. - Field type: The Anqicms provides various field types to meet different data input requirements, including:
- Single-line text: Suitable for short 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 choice: Allow multiple preset options, but only one can be selected, suitable for gender, status, etc.
- Multiple selectionsAllow multiple options to be preset and selected multiple times, suitable for multi-label, multi-functional selection, etc.
- Drop-down selection: Provide a dropdown menu where users select an option from predefined choices, similar to a single choice but differently presented in the interface.
- Mandatory?: You can choose whether this field is required to be filled in when the document is published.
- Default valueIf the field needs to preset a value, it can be entered here.For single choice, multiple choice, and drop-down 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.
Display of custom field on the document editing page
Once a custom field is defined in the content model, it seamlessly integrates 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 Charge' field for an article or to add a 'Material' option for a product, operation personnel can conveniently find and fill in these customized information on the same document editing page.This design greatly simplifies the process of content creation and management, ensuring the completeness and consistency of the information required for different types of content.
Invoke the custom field in the front-end template
The value of the custom field is not only reflected in the background data management, but also in their ability to flexibly present on the front page of the website.AnQi CMS provides powerful template tags, allowing us to easily display custom field content to users.
The most common way is to go througharchiveDetailThe tag 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" %}Display author information.
For scenarios that require iterating through all custom fields, such as displaying a detailed parameter list of a product, you can usearchiveParamsLabel. This label will return an array object containing all custom field names and values, and we can iterate through it using a loop (forLabels) to dynamically display these parameters, greatly enhancing the flexibility and maintainability of the template.
In this way, we can ensure that the presentation form of the website content is highly consistent with the background management structure, realizing true personalized content display.
The Anqi CMS provides powerful content management tools for website operators with its highly flexible content model and intuitive custom field configuration.It not only makes content creation more refined, but also allows website content to better meet the needs of readers, ultimately attracting and retaining users through high-quality, personalized content.
Frequently Asked Questions (FAQs)
Ask: Can I change the type of a custom field after creating it?Answer: Anqi 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 original text data to be incorrectly converted and displayed.Therefore, it is recommended to plan the field types in advance to avoid unnecessary modifications later.
Ask: What will happen if I delete a content model that contains a custom field?Answer: When you delete a content model, the system will prompt you that all documents and categories under the 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 confirm that the deletion will not cause irreversible damage to the website content.
Ask: Does the custom field support 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 function of Anqi CMS, and fill in the corresponding custom field content for each language in these documents.Although the field itself does not provide built-in multilingual translation functionality, multilingual content management can be achieved through site separation.