As an experienced CMS website operation personnel in the information security field, I know that content is the soul of the website, and a flexible content model is the cornerstone for creating and publishing high-quality content.The design concept 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, thus building a website content structure that better fits your business characteristics.
Content Model: Build the skeleton of website content
In AutoCMS, the content model (also known as the document model) is the foundation for defining the types of website content and their attributes.It acts as a blueprint, specifying what information fields should be included in a certain type of content.For example, an 'article' model may include title, body, author, publish date, etc., fields; while a 'product' model may require product name, image, price, stock, detailed description, etc., fields.AutoCMS provides highly flexible content model customization capabilities, allowing you to tailor data structures for each content type based on your actual business scenarios.
The system is pre-installed 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 operation, we encounter various unique content needs, such as 'activity registration', 'course list', 'case display', etc., for which we need to create customized content models to accommodate.
Create new content model
In the AnQi CMS backend management interface, you can manage and create your 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 an intuitive identification for you and your team, such as "Event RegistrationIt will serve as the Chinese name of the identification model and will be displayed in the breadcrumb navigation.
- Model table name: This is the table name used in the database to store the content of the model. Be sure to usein English lowercase lettersThis is a database specification requirement. If other content is entered, it may cause the content to be displayed incorrectly.The table name is usually not recommended to be modified arbitrarily after creation, as it involves the underlying structure of the database.
- URL aliasThis alias is used for pseudo-static rules, for example, in
/{module}/{id}.htmlsuch URL structure,{module}it will be replaced with this URL alias. It also only supportsin English lowercase lettersThis helps to keep the URL tidy and SEO-friendly. - Title nameThis field will be used as the prompt text for the content title when you publish the model content.For example, if you create a “product model”, you can set the title name to “product name”, so 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.
Dedicated fields for custom content models
Created after the basic model, the next step is to add unique "custom fields" to it, which is the essence of the flexibility of the content model.Through 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 exclusive fields for this model. Each custom field requires the following configuration:
- Parameter nameThis is the display name of the field in the background and template, for example, 'Article Author', 'Product Series'.It is usually recommended to set it to English for easy template invocation.The system will automatically convert it to camel case naming for template use, but keeping the original English can also reduce ambiguity.
- Call fieldThis is the actual field name in the database, as well as the identifier for calling it in the template. Please make sure to useEnglish lettersFor example, if your parameter name is "article author", the field name can be set to
author. - field type: The Safe CMS provides various field types to meet different data storage needs:
- Single Line Text:English for storing brief text information, such as "brand name
- Number:Only allows input of numbers, applicable to "price
- Multi-line text:Applicable for storing longer text content, such as "product introduction
- Single selection:Provide preset options, the user can only select one, such as "Product Color", "Size (Single Selection)".
- Multiple selection:Provide preset options, users can select multiple options, such as 'Product features and characteristics', 'Applicable scenarios'.
- Drop-down selection:Similar to single-choice, but presented in the form of a dropdown menu, suitable for situations with a large number of options, such as "Product Classification (Customized)
- Is requiredYou can decide whether this field is required based on your business needs. If set to required, the system will perform validation when content is submitted.
- Default value: Sets a default value for the field, and the system will automatically use this default value when the user does not fill in this field.For the three types of 'Single Choice', 'Multiple Choice', and 'Dropdown Selection', the default value area is used to define their options.Enter an option per line, and the system will automatically parse it as a separate option.
These custom fields will be displayed in the "Other Parameters" collapse box on the document or category edit page during content editing, making it convenient for operations personnel to fill in.
Display custom content in the front-end template
The value of custom fields lies in their ability to present structured data on the website frontend.The Anqi CMS enables flexible calling and display of custom data through its powerful template tag system.
For example, you can usearchiveDetailUse tags to get the 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 loop through all 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, for classified custom fields, you can usecategoryDetailtags in a similar manner.
Through this method, you can completely control the display of each custom field, whether it is as text, image, link, or combined with other content, which can be flexibly realized in the template.
Summary
The content model feature of AnQi CMS is a concentrated manifestation of its strength.Through careful design and custom content models, you can not only efficiently manage various types of information on your website, but also ensure that these information are 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, publication, and optimization, helping your website stand out in the highly competitive digital environment.
Common Questions and Answers (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 English lowercase letters?
“Model Table Name” is the actual name of the data table storing the model data in the database, which belongs to the backend technology category, ensuring the uniqueness and standardization 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 English, 'solutions' could be the URL alias of some model.Both require the use of English lowercase letters to comply with database naming conventions and the friendliness of URLs as well as SEO practices.A properly formatted English lowercase URL helps search engines crawl and understand it, and also helps avoid garbled or compatibility issues that may arise from Chinese or other special characters in the URL.
2. Can I add a carousel of images or multiple image fields in a content model? How to implement it?
Yes, you can do it.In the content model, when adding a custom field, you can select the 'Multiline Text' field type, and then agree on a specific format (such as one image URL per line, or JSON format) for storing image addresses in this field.archiveDetailThe tag retrieves the content of the field and then throughsplitFilter or JSON parsing logic, splits the image URL into an array, and then displays these images.forCycles through and displays these images. For example, if 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 a group of images 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 'Content Management' -> 'Content Model' section of the Anqi CMS backend.When modifying the model, you can adjust the model name, title name, URL alias, or add, delete, or modify custom fields.But please note that modifying the 'model table name' requires great caution, as it directly relates to the database table structure.Delete model is a high-risk operation.All documents and categories are deleted togetherAnd this operation is irreversible.Therefore, before performing the delete operation, make sure that the model and all related content are no longer needed, and it is recommended to perform data backup.Under normal circumstances, it is more recommended to set the model to disabled status rather than directly deleting it.