As an experienced AnQi CMS website operations personnel, I deeply understand the importance of the flexibility of the content model for the efficiency of website operations and the personalized display of content.The powerful content model customization feature of AnQi CMS is the key reason why it has become the preferred tool for small and medium-sized enterprises and content operation teams.Today, let's discuss in detail how to customize the content model field in AnqiCMS and set its type and default value.
Understand the content model of AnqiCMS
In Anqi CMS, the content model is the foundation for defining the structure of various content (such as articles, products, events, etc.).The system is pre-installed with the 'Article Model' and 'Product Model', which provide a set of basic content fields.However, different business scenarios often require more specific and professional fields to carry information.For example, a e-commerce website's product may require fields such as 'brand', 'color', 'size', 'stock unit', etc., and these are not covered by the general model.By customizing the content model fields, we can add unique properties to each content model according to actual business needs, realizing highly personalized content management.
Enter the content model custom field settings
To customize the content model field, you need to log in to the AnqiCMS backend management interface.In the left navigation bar, find the 'Content Management' module and then click on the 'Content Model'.Here, you can see the built-in models of the system as well as the custom models you may have created.Select the specific content model you want to add or modify (whether built-in or custom), click the edit button to enter the detail page.
In the editing interface of the content model, you will see a special area for 'custom fields of content model'.This is the area where we flex our muscles, adding more details to the content.Click the "Add Field" button to open a form that allows you to define the properties of the new field.
Define the properties of custom fields
Each custom field needs to be carefully configured with its properties to ensure it can store and display content correctly.
FirstlyParameter NameThis is the Chinese name displayed on the background management interface, which is convenient for you and your team members to understand its purpose. A clear parameter name can greatly improve the convenience of background operations.
Next isField invocationThis is the template and actual field identifier used in the database.The AnQi CMS recommends using lowercase English letters as call fields to ensure accuracy and stability in internal system recognition and frontend template calls.For example, you can set the call field for "Article Author" toauthor.
The third isField typeThis is the core attribute of a custom field, which determines the type of data it can store and its behavior in the background. Anqi CMS provides a variety of field types for you to choose from to meet different content needs:
- Single-line text: Suitable for short text input, such as article author name, article source, product SKU, etc., which is usually limited to 250 characters to avoid long input content.
- NumberEnsure that the input content is in numeric format. This type is suitable for fields that require numerical calculations or only allow numeric input, such as product inventory, product prices, reading counts, etc.
- Multi-line text: It is used to carry long text content, such as product descriptions, activity rules, user reviews, etc. It provides a larger text input area, allowing for richer content input.
- Single choice:Provide predefined options for users to make single selections. This type is very suitable for scenarios that require standardized options, such as products' 'color', 'size', or articles' 'difficulty level'.The specific content of the option will be defined by the subsequent "default value" field.
- Multiple selections: Similar to single selection, but allows users to select one or more from predefined options.For example, a product may have multiple 'feature' tags, and users can select several of them.The option content is also set in the "default value".
- Drop-down selection: Single selection options are presented in the form of a dropdown menu. When there are many options, it can effectively save space on the backend interface. The content of the options also needs to be defined in the "default value".
The fourth property isMandatory?You can decide whether to fill in this field when publishing content according to your business needs.If a field is crucial for the integrity of the content, such as product price or article title, you can check this option, and the system will perform a check at the time of content publication to avoid missing key information.
Finally isDefault valueThis is a very practical feature that provides default values for new content, reducing the manual input workload.For fields of the 'Single-line text', 'Number', and 'Multi-line text' types, you can directly enter a default text or number here.It is noteworthy that for the three field types of 'Single selection', 'Multiple selection', and 'Dropdown selection', each line in the 'Default value' field will be treated as a separate option.For example, you want a dropdown menu to have "Option A", "Option B", and "Option C", just enter an option per line in the default value input box, and the system will automatically parse one option per line.If a custom field has a default value and you want it to be displayed as the default value when called from the front end, then when publishing content, you just need to leave the field blank, and the system will automatically assign the default value to the field.
By following these steps, you can flexibly customize the fields of the AnQi CMS content model and set appropriate types and default values.This high degree of customization allows AnqiCMS to adapt to various complex business scenarios, helping you manage and display website content more efficiently, thereby attracting and retaining users better.
Frequently Asked Questions (FAQ)
1. Can I delete the built-in "article model" or "product model" of AnqiCMS?The 'Article Model' and 'Product Model' built into the Anqi CMS system can be modified in their fields, but cannot be directly deleted.This is to ensure the core functions and stability of the system's data structure.However, you can customize and create new content models to replace them, and gradually migrate the content to the new models.
2. After creating a custom field, I found that the name of the "invoked field" is incorrect, can I change it?The 'Called field' is a unique identifier directly associated with the database table structure and template call.Once created and put into use, it is generally not recommended to modify it. This may lead to field association errors in published content, and even cause problems at the database level.It is best to delete the field and recreate it if an error is found in the initial creation.If there is already a large amount of data, be sure to back up the data before modification and operate under the guidance of a professional technical personnel.
3. How do I call the custom content model field in the frontend template?In AnqiCMS, you can call custom fields through specific template tags. If the 'calling field' of the custom field isauthorThen in the template of the document detail page, you can use{{archive.author}}to directly call its value. For loop output of all custom fields, you can use{% archiveParams params %}Use the tag to get and traverse all fields and their values. For specific usage, please refer to the AnqiCMS template tag document.archiveDetailandarchiveParamsDescription of the tag.