In the daily operation of websites, we often encounter the need to publish various types of content.In addition to common articles and product displays, you may also need a special "activity list" to post the latest activities, or a "team members" page to showcase the core team of the company, even a "success stories" section to share project experience.AnQiCMS (AnQiCMS) takes full consideration of this flexibility during design, providing powerful custom content model functions, allowing us to flexibly create and manage different types of content structures according to the actual business needs.

How can I create and manage these custom content models in Aiqi CMS, and add exclusive fields for them? In fact, it's simpler than I thought.

Build your content skeleton: Understand and create custom content models

The content model can be understood as the 'skeleton' or 'blueprint' of different types of content.It defines what basic information each content should include, such as an event model may need 'event title', 'start time', 'location', 'registration link', etc.The "Article Model" and "Product Model" are basic skeletons provided by the AnQi CMS by default, which meet most common needs.When your content needs become more diverse, the value of custom content models becomes evident.

To begin creating, we first need to enter the backend management interface of Anqi CMS.In the left navigation menu, find the "Content Management" module and then click to enter the "Content Model" option.Here, you will see the built-in model list of the system, as well as a "Add New Model" button.

Click 'Add new model', we will encounter several key settings:

  • Model name:This is a user-friendly display name, for example, you can fill in "event model" or "team members". It will appear in various content management entry points in the background, making it easy for you to identify and operate.
  • Model Table Name:This is the table name in which the system stores the model data in the database. Please note thatin English lowercase lettersThis is to ensure the standardization and stability of the database. Once set, it is usually not recommended to change arbitrarily, as it is directly associated with your data storage.
  • URL Alias:This field also needs to be usedin English lowercase letters.It is mainly used as an identifier of the model layer when generating pseudo-static URLs.An clear, concise URL alias helps improve SEO effect and user experience./activity/.
  • Title Name:This setting is very thoughtful.It defines the prompt text for the main content field when you create content under the model.For example, in the "Event Model

After completing these basic settings, the skeleton of your content model is set up.But to truly bring this skeleton to life, it still needs to be added with specific 'flesh' - that is, dedicated fields.

Details of injection content: Add specific fields to the custom model

The strength of the model lies in its ability to flexibly define various data fields to meet the storage needs of different content types.When creating or editing content models, you will find the 'Content Model Custom Fields' area at the bottom of the page.Here, you can add, edit, or delete the exclusive fields of the model.

Click 'Add Field' to appear a new form, allowing you to define this field in detail:

  • Parameter name:This is the Chinese display name of this field, such as 'Event Location', 'Registration Deadline', or 'Member Position'.It will be displayed on the background content editing page, making it convenient for editors to understand and fill out.
  • Field call:This is the variable name used when calling this field in the front-end template, which also corresponds to the actual field name in the database. It is recommended to usein English lowercase lettersFor example, 'location', 'deadline', or 'position'. In the template, you can use{{archive.location}}This way to obtain and display data.
  • Field Type:Anqi CMS provides various field types to adapt to different data formats:
    • Single-line text:Suitable for short text input, such as titles, names, etc.
    • Numbers:Only numbers are allowed, suitable for price, quantity, etc.
    • Multi-line text:Suitable for fields that require entering a lot of content, such as event introduction, member profile, etc.
    • Single choice:Allow the editor to select one from the preset multiple options.
    • Multiple selection:Allow the editor to select multiple from the preset multiple options.
    • Dropdown selection:Similar to single selection, but displayed in the form of a dropdown menu to save page space.
    • For the three types of 'Single choice', 'Multiple choice', and 'Dropdown selection', you need to enter one option per line in the 'Default value' field to define the available options.
  • Mandatory:If checked, this field must be filled in when publishing content; otherwise, the submission cannot be completed. This helps ensure the completeness of the content.
  • Default value:If this field usually has a fixed value, or options are defined in a choice field, it can be preset here. Leaving it blank means there is no default value.

Through these steps, you can add any number and type of fields to each custom content model, precisely matching your content needs.

Actual application of content models

When your custom content model and fields are set up, their value will be fully reflected in content operations.

Firstly, when creating new content, you need to select a "category", and each category is associated with a content model.Once you have selected the corresponding category, the content editing interface will automatically load all custom fields defined under the selected content model.So, editors can accurately fill in each item of information according to the field prompt, ensuring that all content is organized according to the preset structure.

Next, when designing the front-end template, you can take advantage of the powerful template tag system of the Anqi CMS (for example,archiveDetailandarchiveParamsLabel),easily call these custom field data and present them on the website. Whether it's displaying the location of an event or the position of a team member, it can be flexible and agile.

Through custom content models, Anqi CMS not only helps us achieve personalized content display, but also greatly improves the adaptability of the website to various business needs, making content management more efficient and orderly.


Common Questions (FAQ)

1. What is the difference between custom content models and built-in "article/product models"? Which one should I choose?

The custom content model provides high flexibility, allowing you to design exclusive content structures and fields based on specific business scenarios (such as events, team members, cases, etc.).The built-in "article model" and "product model" are predefined general structures suitable for most blog posts and product displays.If the content type of your content is significantly different from articles or products, or if you need to capture specific information, creating a custom model would be a better choice. This is because it can make your data structure clearer, more convenient to manage, and more targeted in the front-end display.If your content is highly overlapping with the article or product, you can use the built-in model directly, which can save the steps of customization.

2. How should I call the custom field I created in the front-end template?

Custom fields are usually very intuitive when called in the frontend template. If you set the "field call" to when creating fields in the background,author_name, then in the template of the article detail page, you can directly access it through{{archive.author_name}}To iterate through all custom field names and values of a document, you can use{% archiveParams params %}...{% endarchiveParams %}Label to obtain. Specific usage suggestions refer to the template development document of Anqi CMS.archiveDetailandarchiveParamsDetailed description of the label will have very clear examples.

3. What risks are associated with modifying the 'model table name' or 'URL alias' of the content model?

Modifying the 'model table name' or 'URL alias' carries certain risks, especially when the website has already been launched and contains a large amount of data.

  • Model Table Name:It is the actual table name stored in the database.If modified, it may cause the system to be unable to find the original data, resulting in data loss or page errors.Therefore, once set, it is strongly recommended not to change it.
  • URL Alias:It is an identifier used to generate page URLs.Changing it will cause the URL of all the content under the model to change.This will affect the website's SEO (Search Engine Optimization) because search engines will consider these pages as new or missing, which may lead to a decrease in traffic.If it is indeed necessary to modify, it is imperative to use the 301 redirect function to permanently redirect the old URL to the new URL to minimize SEO impact as much as possible.