As an experienced security CMS website operation personnel, I know that content is the soul of the website, and a flexible content model is the foundation for supporting high-quality content creation and publication.The design philosophy of AnQi CMS in this aspect is to give operators greater freedom and adaptability to meet the ever-changing business needs and reader expectations.This article will detail how to create and customize new content models in Anqi CMS, thereby building a website content structure that is more tailored to your business characteristics.
Content Model: The framework for constructing website content
In Anqi CMS, the content model (also known as the document model) is the foundation for defining the type of website content and its properties.It is like a blueprint, specifying what information fields a certain type of content should include.For example, an "article" model may contain fields such as title, body, author, publish date, etc.And a "product" model may require fields such as product name, image, price, inventory, detailed description, etc.AnQi CMS provides highly flexible content model customization capabilities, allowing you to tailor data structures for each content type according to your actual business scenarios.
The system is default built-in with 'Article Model' and 'Product Model' which are commonly used models. These built-in models can be modified but cannot be deleted.For our daily operations, we encounter various unique content needs, such as "activity registration", "course list", "case display", etc., and we need to create customized content models to accommodate them.
Create a new content model
On the AnQi CMS backend management interface, you can manage and create content models through the 'Content Management' module under the 'Content Model' feature.
To create a new content model, you need to pay attention to the following core configuration items:
- Model nameThis is a direct and intuitive identifier for you and your team, such as 'Event Registration', 'Solution'.It will serve as the Chinese name for the recognition model and will be displayed in the breadcrumb navigation.
- Model table nameThis is the table name used to store the content of the model in the database. Please make sure to useEnglish lowercase lettersThis is the database specification requirement, if other content is filled in, it may cause the content to be displayed incorrectly.This table name is usually not recommended to be changed arbitrarily after creation, as it involves the underlying database structure.
- URL aliasThis alias is used for calling pseudostatic rules, such as in
/{module}/{id}.htmlsuch URL structure,{module}it will be replaced with this URL alias. It also supportsEnglish lowercase lettersThis helps maintain the neatness and SEO-friendliness of the URL. - Title NameThis field will be used as the prompt text for the title of the content you publish with this model.For example, if you create a "product model", you can set the title name to "product name", so that when you publish the product, the operation interface will display "product name" as the input prompt, which is more in line with the business context.
When creating a model, please be cautious. Especially when deleting a model, as it has a 'cascading effect', once the model is deleted, all its subordinate documents and categories will also be permanently deleted. This is an irreversible operation.
Exclusive field for custom content model.
After creating the basic model, the next step is to add unique "custom fields", which is the essence of the flexibility of the content model.By custom fields, you can ensure that each content type has the specific data required by its business logic.
In the content model editing interface, you can set dedicated fields for the model. Each custom field requires the following configuration:
- Parameter NameThis is the Chinese name of the field displayed in the background and template, such as "article author", "product series".It is usually recommended to set it to English for convenience when calling the template.The system will automatically convert it to camel case for template use, but keeping the original English can also reduce ambiguity.
- Field invocationThis is the actual field name in the database, as well as the identifier used in the template. Please make sure to useEnglish lettersFor example, if your parameter name is "article author", the calling field can be set to
author. - Field type: Anqi CMS provides various field types to meet different data storage needs:
- Single-line text: Suitable for storing brief text information, such as 'brand name', 'contact number', limited to 250 characters.
- Number: Only numbers are allowed, suitable for 'price', 'stock quantity', etc.
- Multi-line text: Suitable for storing long text content, such as 'product description', 'instructions', etc.
- Single choice: Provide preset options that the user can select from, for example, "Product color", "Size (single selection)".
- Multiple selectionsProvide preset options for users to select multiple items, such as "Product Features" and "Application Scenarios".
- Drop-down selection: Similar to single selection, but presented in the form of a dropdown menu, suitable for situations with many options, such as "Product classification (customized)".
- Mandatory?: You can decide whether the field is required according to your business needs. If set to required, the system will check the content when it is submitted.
- Default valueThe field is set to the default value, which the system will automatically use if the user does not fill in this field.For the 'Single choice', 'Multiple choice', and 'Dropdown' types, the default value area is used to define their options.Enter an option per line, the system will automatically parse it into separate options.
These custom fields will be displayed in the "Other Parameters" collapse box on the document or category editing page during content editing, convenient for operators to fill in.
Display custom content in the front-end template.
The value of a custom field lies in its ability to present structured data on the website front-end.The Anqi CMS enables flexible calling and display of custom data through its powerful template tag system.
For example, you can usearchiveDetailTag to get details of a single document andname="您的自定义字段名"to directly get the value of this custom field.
{# 假设您为产品模型定义了一个名为“产品系列”,调用字段为“series”的自定义字段 #}
<div>产品系列:{% archiveDetail with name="series" %}</div>
If you want to cycle through all the custom parameters of a document, you can usearchiveParamsTags:
{% archiveParams params %}
{% for item in params %}
<div>
<span>{{item.Name}}:</span>
<span>{{item.Value}}</span>
</div>
{% endfor %}
{% endarchiveParams %}
Similarly, you can use for category custom fieldscategoryDetailTags can be called in a similar manner.
In this way, you can fully control the display of each custom field, whether it is as text, image, link, or combined with other content, all can be flexibly realized in the template.
Summary
The content model function of AnQi CMS is a concentrated embodiment of its strength.By carefully designing and customizing the content model, you can not only efficiently manage various information on the website, but also ensure that this information is presented to users in the most suitable way for your business logic.As a website operator, mastering this core feature will greatly enhance your efficiency and effectiveness in content creation, publishing, and optimization, helping your website stand out in the highly competitive digital environment.
Frequently Asked Questions (FAQ)
1. What is the difference between "model table name" and "URL alias" when creating a content model? Why are they both required to use lowercase English letters?
“Model Table Name” is the actual name of the database table storing the model data, which belongs to the backend technology category, ensuring the uniqueness and specification of data storage. While “URL alias” is used as an identifier in the front-end web page URL structure, for example,yourdomain.com/solutions/detail-1.htmlIn, "solutions" may be the URL alias of some model.Both require the use of English lowercase letters to comply with database naming conventions, URL friendliness, and SEO practices.A standard English lowercase URL is helpful for search engines to crawl and understand, and can also avoid garbled or compatibility issues caused by Chinese or other special characters in URLs.
2. Can I add a picture carousel or multiple picture fields in a content model? How can I implement it?
Yes, you can achieve it. When adding custom fields in the content model, you can choose the 'Multi-line text' field type, and then agree on a specific format (such as one image URL per line, or in JSON format) to store image addresses.In the front-end template, you can usearchiveDetailTags get the content of the field and then go throughsplitThe filter or JSON parsing logic splits the image URL into an array, and thenforcycles through and displays these images. For example, if you have custom fieldsproduct_imagesStored multiple image URLs, you can call it in the template like this:{% archiveDetail images with name="product_images" %}
{% for img in images %}<img src="{{img}}" alt="产品图片" />{% endfor %}This can display an image group on the front end.
How to modify or delete existing content models? What should be noted?
You can find and edit or delete existing content models in the Anqi CMS background "Content Management" -> "Content Model". When modifying the model, you can adjust the model name, title name, URL alias, or add, delete, or modify custom fields.Please note that modifying the 'model table name' requires great caution as it directly relates to the database table structure.Deleting a model is a high-risk operation. Anqi CMS explicitly states that deleting a model will cause the model to be deleted belowAll documents and categories are deleted togetherThis operation is irreversible. Therefore, be sure to confirm that you no longer need the model and all related content before performing the delete operation, and it is recommended to back up the data.In most cases, it is recommended to disable the model that is no longer in use instead of deleting it directly.