AnQi CMS is an efficient and customizable enterprise-level content management system, one of its core highlights is the "flexible content model".This feature greatly expands the management boundaries of website content, allowing us to create various unique content structures according to actual business needs.Among these, the custom field (also known as custom parameter) plays a vital role, allowing our website content to go beyond traditional article titles, content, and summaries, and carry more personalized information, ultimately displaying flexibly on the front page.
Flexible content model and the foundation of custom fields
Imagine a traditional CMS that might only provide two fixed content types such as 'articles' or 'products.'If we need to publish an 'event' or a 'case', which includes the start time, location, number of registrants, customer name, industry background, and other unique information, these fixed content types seem inadequate.
The flexible content model of AnQi CMS is precisely designed to solve such problems.It allows us to customize content types, such as creating an "event model" and adding a series of exclusive custom fields for this model.These custom fields are where the model carries specific information outside of the standard fields.They are the foundation of website personalized content, enabling each content model to accurately match its business attributes, thus achieving more refined and efficient content management.
Practical steps for creating and managing custom fields in the background
In the AnQi CMS backend, managing custom fields is an intuitive and powerful process.Generally, we need to go to the 'Content Management' menu to enter the 'Content Model' settings.Here, you will see the system built-in 'article model' and 'product model', and you can also create new content models.
Whether it is to edit an existing model or create a new model, the core steps are to enter the model details page, find the "Content Model Custom Fields" area. Here, we can add the required fields like building blocks:
- Parameter name:This is the field display name seen in the background management, such as 'Event Start Date', 'Customer Industry'.
- Call field:This is the unique identifier that needs to be used when calling this field in the front-end template. It is recommended to use letters to maintain code specifications, and usually in camel case (for example:
activityStartTime/customerIndustry)。This name is crucial, as the front-end recognizes and retrieves field content through it. - Field type:Anqi CMS provides various field types to meet the needs of entering different data.
- Single-line text:Applicable for short texts, such as titles and abbreviations.
- Number:Ensure that the entered data is purely numeric, such as prices and quantities.
- Multi-line text:Suitable for longer descriptions, such as product features and event details.
- Single choice, multiple choice, dropdown choice:These three types are very suitable for preset options, such as "Activity status (Ongoing/Completed)", When setting these types, the "Default Value" area becomes the place to define the option list, one per line.
- Mandatory?:According to business needs, some fields can be set as required to ensure that important information is not missed.
- Default:Set an initial value for the field to improve the efficiency of content publication. For selection type fields, it is used to set optional items here.
After the custom field is set up, save the model. After that, when publishing the corresponding content model (such as a new event under the "event model"), in the "other parameters" area of the content editing interface, we can see the custom field just added and can fill in specific content for them.
Flexible calling and display of custom fields on the front-end page
Presenting the content of a custom field to the user is a key step in the content management cycle of AnQi CMS. AnQi CMS's template engine syntax is similar to Django, very intuitive, mainly through double curly braces{{变量}}to output variable content, as well as{% 标签 %}Structure to use feature tags.
Call custom fields on a single document detail page:
When you enter a detailed page of an article, product, or event, the main data of the page will usually be accessed through a name calledarchive(for articles or products) orcategoryThe global variable to carry for the category page. If your custom field (assuming the called field isauthor) is directly associated with the document, you can directly access it through{{ archive.author }}This is the way to output its content.
If your custom field is an image group, a checkbox, or other complex type, or if you want to have more flexible control over the output, you can usearchiveDetailTags:
`twig {# Directly retrieve the content of a custom field by name, such as the author of an article #}
If custom field content contains HTML, the |safe filter must be used to prevent escaping #
{# Call the custom field of the image group, such as “Product Group Image”, it will return an array, need