As a long-term operator specializing in AnQiCMS, I know that content is the lifeline of a website, and flexible and scalable content management capabilities are the foundation of efficient operation.One of the core features provided by AnQiCMS in content management is its powerful custom content model mechanism.This greatly endows us with the ability to calmly respond to diverse content needs and achieve personalized display.
The following will introduce how to create and manage custom content models in AnQiCMS, and add personalized fields to these models to help you better build and optimize your website content.
Understand the content model in AnQiCMS
In AnQiCMS, the content model is a blueprint used to define the structure and properties of a type of content.Imagine that your website may not only have 'articles', but also 'products', 'cases', 'events', and other types of content.Each content has its unique properties, such as products may have 'price', 'inventory', while articles may have 'author', 'source'.The AnQiCMS content model allows us to create dedicated structures for each content type, ensuring that each piece of content can be stored and displayed accurately and completely with its necessary information.This not only improves the efficiency of content management, but also provides a solid data foundation for the personalized display of the front end.
AnQiCMS system is default built-in with 'article model' and 'product model', but when these default models cannot meet your business needs, a custom content model becomes your powerful tool.
Create a new custom content model
To create a completely new content model, you need to enter the AnQiCMS backend management interface.In the left navigation bar, find and click "Content Management", then select "Content Model".
On the content model management page, you will see a list of all existing content models. Click the 'Add Model' button, and the system will guide you to fill in the basic information of the new model:
- Model nameThis is the display name of the model in the background management interface, it is recommended to use Chinese, concise and clear, for example, 'Case Display', 'Team Members'.This name will also appear in the breadcrumb navigation as the model level name.
- Model table nameThis is a key field that determines the table name in the database where the custom data of the model is stored. Please make sure to useEnglish lowercase lettersName it, this is the foundation for data storage in the system. Improper naming may cause the data to be displayed or stored incorrectly.
- URL aliasThis is the identifier used in the front-end URL of the model, which also only supportsEnglish lowercase lettersIt will appear in the pseudo-static rule, for example
{module}The variable refers to this URL alias, which is crucial for SEO and URL readability. - Title NameThis field affects the hint text in the article title input box when you publish the model content.For example, if you create a "product
After filling in this basic information, your custom content model is initially created.
Manage and maintain existing content models
After creating the model, you may need to modify it or delete it in certain situations. AnQiCMS manages built-in models and custom models differently.
The built-in "article model" and "product model" can be modified to adapt to more refined demand adjustments, but they are part of the core functions of the system, thereforecannot be deleted.
For the custom model you have added yourself, you can modify and delete it according to business changes.On the model list page, click the 'Edit' button of the corresponding model to enter the modification interface.Here, you can adjust the model name, URL alias, and title name information.
Please be cautious when dealing with the delete operation.When you decide to delete a custom model, AnQiCMS will prompt you, after deleting the model, the model under it willAll document content and related categories will be permanently deletedThis is an irreversible operation, please confirm the importance of the data before executing.
Add personalized fields to the model
The true strength of the content model lies in its ability to add various personalized fields according to specific needs.For example, a "product" model may require fields such as "brand
On the model editing page, you will see an area named "Content Model Custom Field". Click "Add Field" to define new personalized properties for the model:
- Parameter NameThis is the Chinese name of the field displayed in the background management interface, such as "article author", "product price". It should clearly describe the purpose of the field.
- Field invocationThis is the field name stored in the database, as well as the identifier you use when calling data in the front-end template. Please useEnglish lettersas a call field, for example
author/price. Proper naming helps in subsequent template development and data maintenance. - Field type: AnQiCMS provides various field types to meet the storage needs of different data:
- Single-line text: Suitable for short text input, such as titles, brief descriptions, with a length limit of 250 characters.
- Number: Only numeric input is allowed, suitable for prices, inventory quantities, etc.
- Multi-line text: Suitable for long text content, such as detailed descriptions, product introductions.
- Single choice: Provides multiple preset options, the user can only select one, such as "gender" (male/female).
- Multiple selectionsProvide multiple preset options, the user can select multiple items, such as "Product Color" (Red/Blue/Green).
- Drop-down selection: Similar to single selection, but presented in a dropdown menu, saving page space.
- Mandatory?: You can specify whether this field is required when publishing content. If set as required, the system will check during submission.
- Default valueIf the field usually has a fixed or recommended initial value, you can set it here.It should be noted that for the three types of 'single choice', 'multiple choice', and 'drop-down selection', the default value area is used to fill in all the available options, each option occupying a line.The system will automatically parse each line as an option.
By following these steps, you can build a unique data structure that best fits the business logic of each content model.
The practical application of content models and template calls
When the content model and its personalized field configuration are completed, its value will be reflected in the content publishing and front-end display stages.
When releasing content (for example, "Content Management" -u003e "Publish Document
In the front-end template, to call these custom fields, AnQiCMS provides flexible tag support. For example, for the document detail page, you can call the custom fields like this:
- Loop to display all custom fields:
{% archiveParams params %} <div> {% for item in params %} <div> <span>{{item.Name}}:</span> <span>{{item.Value}}</span> </div> {% endfor %} </div> {% endarchiveParams %} - Directly call a specific custom field:
If you have customized a field named
authorfield, you can use it directly:<div>作者:{% archiveDetail with name="author" %}</div> - Call complex custom fields such as charts:
If your custom field is a chart (for example, calling the field name
arcimages), you can display it in the template like this:
These flexible calling methods allow you to implement a variety of display effects on the front end based on the characteristics of different content models.{% archiveDetail arcimages with name="arcimages" %} <ul class="arc-images"> {% for img in arcimages %} <li><img src="{{img}}" alt="自定义图片" /></li> {% endfor %} </ul>
Summary
AnQiCMS' custom content model feature is one of its core competitive advantages, granting website operators great freedom and flexibility.By precisely defining the content structure and personalized fields, we can not only improve the efficiency of content production and management, but also provide users with highly customized, rich information content experience.Make full use of this feature, your website will be able to better adapt to the ever-changing market needs and attract and retain more target users.
Frequently Asked Questions (FAQ)
1. Can I modify the built-in 'Article Model' or 'Product Model' of AnQiCMS system?Yes, you can modify the basic information of the "article model" and "product model" built into AnQiCMS and add custom fields. However, in order to ensure the stable operation of the core functions of the system, these built-in modelsCannot be deleted.
What are the consequences of deleting a custom content model?Deleting a custom content model is a behavior that requires careful operation.Once the model is deleted, all the contents (documents) belonging to the model and all the classifications associated with it will be permanently deleted and cannot be recovered.Therefore, please make sure to backup the data and confirm that you no longer need the model and all related content before performing the delete operation.
How to call personalized fields added by a custom content model in the front-end template?In the AnQiCMS front-end template, you can usearchiveDetailorarchiveParamstags to call custom fields.
archiveDetail with name="调用字段名": you can directly retrieve and output the value of a specific custom field, for example{% archiveDetail with name="author" %}.archiveParams params: Can retrieve an array or map (depending onsortedthe parameter), thenforloop through to display each field'sNameandValueFor example,{% archiveParams params %}{% for item in params %}{{item.Name}}:{{item.Value}}{% endfor %}{% endarchiveParams %}.