In AnQi CMS, using the content model to flexibly define the display form of articles is one of its core advantages.It allows your website content to go beyond traditional 'articles' or 'products' formats, and instead, present a variety of content structures based on actual business needs.
Understanding the core value of the content model
In the digital world, the content carried by websites is much richer than we imagine.In addition to common blog posts or product details, you may also need to display company events, job openings, successful cases, course lists, as well as real estate information or car configurations.This content type varies, each with unique data structures and display requirements.For example, a "job posting
The traditional CMS systems often have strict restrictions on content structure, forcing you to adapt through compromise or workaround.But the "Flexible Content Model" feature of Dananqi CMS is designed to solve this pain point.It allows you to freely create and customize content models according to your business logic, build the most matching data structures for each type of content, thereby greatly enhancing the adaptability of the system and the management efficiency of content.The built-in "article model" and "product model" are the foundation, while the custom model opens up endless possibilities.
Custom content model: Build data structure from zero to one
To start customizing the display format of content, you first need to start with the content model itself.
- Enter the content model management interface:Log in to the Auto CMS backend, you will find the "Content ManagementClick to enter, and you will see the built-in "Articles" and "Products" models, as well as the custom models you create in the future.
- Create or edit the model:You can choose to edit an existing model, or click 'Add New Model' to create a completely new content type. During the creation process, several key properties of the model need to be defined:
- Model name:This is the Chinese name identified in the background management interface for this model, for example “Recruitment Position”, “Successful Case”, or “Online Course”.
- Model Table Name:This is an English lowercase letter name used internally by the system, for storing the data of this model in the database.For example, “job”, “case” or “course”.
- URL Alias:It is lowercase English letters, which will be used to construct the URL address of the content of this model, for example
yourdomain.com/job/xxx. - Title Name:This is the prompt text for the title field when publishing content under this model, for example, "Position Name" instead of the generic "Document Title".
- Core: Custom field settings:This is the most flexible part of the content model. You can add exclusive fields for each model to store information unique to that content type. Click 'Add Field' to configure:
- Parameter name:This is the Chinese display name of the field when managing in the background, for example, 'Salary Range', 'Event Location'.
- Field call:This is the English name used when referencing this field in the template, recommended to use camel case naming, such as
salaryRange/activityLocation. This name is the key to connect backend data with frontend display. - Field Type:The Auto CMS provides various field types to adapt to different data formats:
- Single-line text:Suitable for brief text information, such as “Product Model”, “Event Theme”.
- Numbers:Ensure the input is a number, such as 'inventory quantity', 'price'.
- Multi-line text:Suitable for long descriptive content, such as 'event details', 'job description'.
- Single choice/multiple choice/dropdown selection:These types allow you to preset a series of options, from which users can select (single choice/dropdown) or select multiple (multiple choice).They are very suitable for defining fixed options such as 'product color', 'size', 'activity status', etc.
- Mandatory:Control whether this field is required when publishing content.
- Default value:Provide preset values for the field to facilitate content publishing.
Present custom data on the frontend: flexible application at the template level
Once the content model and custom field definitions are completed, the next step is how to elegantly present it on the website's frontend.The template engine of Anqi CMS provides powerful tags and flexible mechanisms, allowing you to finely control the display of every part of the content.
The correspondence between models and templates:AnQi CMS follows a set of intuitive template naming conventions. For example, if you create a template named
jobcontent model, then:- The list page template of this model is usually
{模型table}/list.html, which isjob/list.html. - The detail page template of this model is usually
{模型table}/detail.html, which isjob/detail.html. You can place these template files in the corresponding directory of your current theme.Moreover, Anqi CMS supports specifying custom templates for specific individual articles or categories, which provides finer control. You can specify a custom HTML file path in the "Document Template" or "Category Template" field when editing articles or categories in the background.
- The list page template of this model is usually
Core: How to call custom fields in the template:Once the data structure is defined in the background, you can use the template tags of Anqi CMS in the front-end template to call these data.
- Display custom fields for a single content on the detail page:For like
job/detail.htmlFor such a detail page, you will need to display specific information about the current job posting. At this time,archiveDetailandarchiveParamsthe label comes in handy:- Direct call:many custom fields can be displayed directly through
{{archive.调用字段名}}The form of access. For example, if you have customized a field name for callingsalaryRange
- Direct call:many custom fields can be displayed directly through
- Display custom fields for a single content on the detail page:For like