In the daily operations of website management, the flexibility of the Content Management System (CMS) is crucial.Traditional CMS may only provide fixed models such as "articles" and "products", but this limitation becomes evident when facing rapid business changes and personalized content display needs.AnQiCMS (AnQiCMS) fully understands this point, therefore it provides powerful custom content model features, allowing operators to build content structures that fully meet their own needs according to business characteristics.

Today, let's delve into how to create and manage custom content models in AnQiCMS, and add the required fields to unlock the limitless possibilities of your website's content.

Why do you need to customize the content model?

Imagine that you are running a real estate information website, in addition to regular articles and news, you also need to publish 'real estate information'.Each plot not only has a title and content, but also a series of unique attributes such as 'house type', 'area', 'price', 'developer', 'traffic support' and so on.If we force this information into a general article model, it will not only be difficult to manage, but the front-end display will also be very difficult.

This is the time when the custom content model really shines.It allows you to define a dedicated structure for specific types of content, ensuring that each piece of information is properly organized and stored.Whether it is the 'ingredients' and 'cooking steps' of a 'recipe', or the 'start time', 'location', and 'number of participants' of an 'event', AnQi CMS can easily help you build these personalized content frameworks.This has greatly improved the efficiency of content management and also laid a solid foundation for accurate front-end display and user experience optimization.

Create your first custom content model

In the AnQiCMS backend, the operation path for managing custom content models is very intuitive. You just need to navigate toContent Managementand then clickContent modelOptions, you can enter the content model management interface.Here, you will see the built-in "article model" and "product model", as well as other custom models you may have created.

To create a completely new model, click the "Add Model" button on the interface, the system will guide you to fill in some basic information:

FirstlyModel name.This is a Chinese name, convenient for you to identify and manage in the background, such as 'real estate information', 'complete recipe' and so on.It will also appear in the breadcrumb navigation in the background, helping you to clarify the content type of the current operation.

Next isModel table name. This is the table name used by the system to store the model data in the database, therefore it must be usedEnglish lowercase lettersThis name is crucial, it ensures the uniqueness and standardization of data storage. Please make sure to choose a concise and meaningful English word.

Then it isURL aliasThis is also usedEnglish lowercase lettersIt will be used to build the URL structure of the website content, for example, in the pseudo-static rules, your custom model content may start with/module-alias/detail.htmlIt is displayed in the form. A clear, semantic URL alias is very beneficial for SEO and user-friendliness.

Finally isTitle Name.This is a flexible prompt text, used when you publish new content to prompt the content editor for the meaning of the current main content field.For example, if your model is "real estate information

Complete these basic information and save, your custom content model skeleton is set up.

Add dedicated fields to the model

After creating the model, the next step is to add specific fields to make the content truly rich.On the content model editing page, you will see a 'Content Model Custom Field' area.Click 'Add field', you will enter the field configuration interface.

Each custom field needs to define the following key attributes:

Parameter NameThis is the display name of the field in Chinese, such as 'Type', 'Area', 'Price', etc., which will be directly displayed on the content editing interface, convenient for editors to understand and fill in.

Field invocationThis is used to call the field data in the template, so it must be usedEnglish lettersFor example, if your parameter name is "house type", the field to be called can be set tohouseTypeFollow camelCase naming conventions (such ashouseAreaInsteadhouse_area) is a good practice.

Field type: AnQiCMS provides various field types to meet different data storage needs:

  • Single-line text: Suitable for short text input, such as 'Developer Name', 'Traffic Route'.
  • Number: Designed for numerical data, such as 'Sales Price', 'Floor Area'.
  • Multi-line text: Suitable for long text descriptions, such as 'property introduction', 'community features'.
  • Single choiceWhen you need to select one from a preset multiple options, for example, 'decorating situation' (bare, finished, simple finishing).
  • Multiple selections: Allow selecting zero, one, or multiple from multiple preset options, such as 'Support Facilities' (schools, hospitals, parks, supermarkets).
  • Drop-down selection: Similar to single selection, but presented in a dropdown menu, saving page space.

For the three types of "Single selectionDefault valueSet specific options for them, one option per line, the system will automatically parse and provide it to the editor for selection.

Mandatory?: You can choose whether a field is required based on its importance. If checked, the system will prompt for verification if the field is empty when the content is published.

Default value: In addition to the option settings for selecting types, for text and numeric field types, you can also set a default value to reduce the workload of content editing.

By combining these field types, you can build an extremely refined and structured content model to meet various complex business scenarios.For the "Real Estate Information

Content publishing and template invocation

After you have created the custom content model and its fields, when you publish content, you first need to select a category associated with the model (you can create and associate models in the document category).Once you select the corresponding category, the content editing interface will automatically display all the custom fields you defined for the model, for you to fill in.

In the front-end template, to display the data of these custom fields, Anqi CMS provides convenient template tags. You can usearchiveDetailtags to get the value of a single custom field, for example{% archiveDetail with name="houseType" %}The apartment type information of the current content can be displayed. If you want to traverse all custom fields or display in a more flexible way,archiveParamsThe tag will be a good helper for you, it can return all custom fields in an array form, allowing you to easily loop output in the template.

In this way, Anqi CMS not only helps you efficiently manage structured content on the back end, but also allows front-end developers to easily call and display these personalized data, thereby creating more attractive and high-quality websites that meet user needs.

Operation strategy and **practice

Creating and managing a custom content model is not a one-time task. In actual operation, some strategies and practices can help you better utilize this feature:

Plan firstBefore creating any models and fields, it is essential to communicate thoroughly with the content team and product team to clarify the content type, required properties, and future scalability.A detailed content structure diagram would be a good start.

Naming convention: The table name and field names called by the model (i.e., database field names) should follow clear and unified English naming conventions.This helps maintain the neatness of the background data structure and is convenient for subsequent template development and secondary expansion.

Consider SEOThe custom model URL alias affects the URL structure, be sure to choose meaningful English words, and combine it with AnQiCMS's pseudo-static function to optimize the SEO friendliness of the URL.

Step by step

The AnQiCMS custom content model feature grants website operators great freedom, it upgrades your website from a static information display platform to a dynamic ecosystem that can flexibly respond to various content challenges.

Frequently Asked Questions (FAQ)

Q1: What is the relationship between the custom content model and 'Document Classification'?A1: Custom content models define the "skeleton" of content, and "document classification" is the categorization of content under this skeleton.Each category must be associated with only one content model.When you post content, you must first select a category, and then the system will display the corresponding custom fields for you to fill in based on the model associated with that category.This means that if your "property information" model can have different categories such as "new houses

Q2: What will happen if I delete a custom content model?A2: Deleting a custom content model is a very important operation as it will also delete all associated document content and the corresponding categories.The system will provide a clear warning to ensure that you fully understand the impact before performing this operation.Therefore, please consider carefully before deleting any custom models and confirm that the relevant content has no retained value or has been backed up.

Q3: How to display the custom field I added in the front-end template?A3: To display custom fields on the website front end, you need to edit the corresponding template file. AnQiCMS providesarchiveDetailandarchiveParamssuch template tags.

  • If you want to directly display the value of a specific custom field, you can use{% archiveDetail with name="您的调用字段名" %}For example,{% archiveDetail with name="houseType" %}.
  • If you want to iterate over all custom fields under the content model and display them, you can usearchiveParamsLabel: `{{ archiveParams params }}{% for item in params %}`{{item.Name}}:{{item.Value}}{% end