In website operation, we often encounter such situations: different types of content require different fields to describe and display.For example, a news article may only need a title, content, and publication time;A product detail page may need product name, price, inventory, image set, detailed parameters, etc.If all the content is squeezed into a fixed template or data structure, not only will it be chaotic to manage, but the front-end display will also be inadequate.

AnQiCMS deeply understands the importance of content diversity, and therefore provides powerful content model customization features, which is the core of solving such problems.By using a flexible content model, we can create dedicated data structures for different types of content according to actual business needs, thereby achieving personalized and efficient content management and display.

Understanding the Content Model: The Basics of Content Structure

A content model, simply put, is a set of rules that defines which fields a certain content type includes, what types those fields are, and how they are managed in the background.AnQiCMS is built-in with the common content models such as 'Article Model' and 'Product Model', which provide basic field structures for articles and products.However, the needs of website operation are not limited to this, AnQiCMS allows us to create or modify custom content models on this basis to meet a variety of complex scenarios from corporate websites, marketing sites to product displays.

Custom content model: Flexible customization

AnQiCMS's content model customization capability is one of its highlights.To start customization, we can go to the "Content Management" module in the background and find the "Content Model" option.Here, you can not only view and modify the built-in models of the system, but also add new models according to your own needs.

When creating or modifying a content model, we need to pay attention to several key settings:

  • Model nameThis is the display name of the model in the background, for example, "activity model", "case model".
  • Model table nameThis is the table name stored in the database for the model data, it is recommended to use lowercase English letters to ensure uniqueness.
  • URL aliasUsed in pseudo-static rules, it determines the way the model's content is represented in the URL, and it is also recommended to use lowercase English letters.
  • Title NameThis setting is very thoughtful, it will serve as the prompt text for the main title field when publishing content.For example, if your model is "product", you can set the "title name" to "product name" to make it clearer for content entry personnel.

However, the true power of the content model lies in the “Custom fields for content modelHere. It allows us to add exclusive data fields to the model, just like adding different columns to different types of tables. The configuration options for custom fields are diverse:

  • Parameter Name: Field display name in Chinese, convenient for background management and understanding, such as 'author', 'contact phone', 'event location'.
  • Field invocationThis is the English name stored in the database, which is also the unique identifier used when calling the template, for exampleauthor/contactPhone/location.
  • Field type: AnQiCMS provides various field types to accommodate different data entry and display needs:
    • Single-line textThis is suitable for short text information, such as author name, product model.
    • NumberMake sure to enter numbers, suitable for prices, inventory, quantities, etc.
    • Multi-line textSuitable for longer inputs, such as product descriptions, event introductions.
    • Single choiceProvide preset options, the user can only select one, such as product color, size (small, medium, large).
    • Multiple selectionsProvide preset options, the user can select multiple, such as product features.
    • Drop-down selection: Similar to single selection, presented in a dropdown menu.
    • For selection fields, we can also setDefault valueThese default values will be the optional items for users.
  • Mandatory?: It can be required to fill in this field by the content publisher to avoid data omission.

For example, you can create a "event model" and add custom fields such as "event topic (single-line text)", "event details (multi-line text)", "event location (single-line text)", "registration fee (number)", "event date (date selection)" and so on.This way, when an event is published, the backend will display these exclusive fields for filling in.

Combining content entry with model fields

Once the content model and its custom fields are defined, they will take effect during the actual content publishing process.When we choose a content category (each category is bound to a content model) for publication, in addition to the universal fields such as title, content, thumbnail, etc., the "Other Parameters" area will automatically display all the custom fields under the content model.Content editors only need to fill in these fields as needed, greatly improving the structuralization degree and input efficiency of the content.

Flexible invocation and display in the template

It is not enough to define fields only in the background, the key is how to beautifully display these data on the front page.AnQiCMS powerful template tag system provides convenience for this.

  • Association between template and modelThe template file naming conventions of AnQiCMS follow certain rules, for example{模型table}/detail.htmlUsed to display the details page of the model,{模型table}/list.htmlUsed to display the list page. This means that different content models can automatically use exclusive templates to display.
  • Get model information: Use.moduleDetailTags can obtain detailed information about the current model or a specified model, such as the model name, URL alias, etc.
  • Display custom field: On the content detail page, we can use it directly.{{archive.调用字段名}}The form to call the value of a custom field. For example, if a custom field is calledauthorThe field, it can be used directly.{{archive.author}}To display the author. For custom fields that need to be displayed in a loop (such as an image gallery fieldarcimages), then you can use{% archiveDetail arcimages with name="arcimages" %}CombineforLoop to traverse and display.
  • Custom fields on the category page: Similarly,categoryDetailTags also support calling custom fields defined in the classification model, whether accessed directly or throughextrasloop iteration, can achieve customized display.
  • Advanced filtering function:archiveFiltersTags allow us to generate filtering conditions based on custom model fields, which is very practical for websites that need to search and filter content across multiple dimensions (such as real estate, recruitment, e-commerce, etc.)We can build complex filtering interfaces based on these custom fields, greatly enhancing the user experience.
  • Logical Control and Iteration: CombinedifLogical judgment tags andforLoop through tags, we can dynamically adjust the display of content based on whether a custom field exists, its type, or its value, even nested calls to other template fragments (include)or macro function(macro),to achieve highly flexible page layout.

For example, for the "event model" mentioned earlier, in the template of the event detail page, we can use{{archive.activityLocation}}Show the event location through{{archive.registrationFee}}Show the registration fee. If the registration fee is 0, we can use{% if archive.registrationFee == 0 %}免费报名{% else %}报名费用:{{archive.registrationFee}}元{% endif %}to dynamically display.

actual application under various needs

The custom content model plays an indispensable role in various website operation scenarios:

  • E-commerce website: Besides basic product information, you can customize fields such as "size", "color", "material", "brand", "applicable population", and display them in the details page and list filtering.
  • Real estate agency website: You can customize fields such as 'House Type (Apartment, Villa, Office Building)', 'House Type (One Room, Two Rooms, Three Rooms)', 'Area', 'Floor', 'Decorative Condition', and provide multi-dimensional search.
  • News Portal/BlogBesides the article content, you can customize fields such as 'Source', 'Author Introduction', 'Recommended Reading', 'Special Topics', etc.
  • Event Registration WebsiteCustomize fields such as 'Activity Type', 'Start/End Time', 'Application Deadline', 'Organizer', 'Co-organizer', and others.
  • Recruitment website:Customize fields such as "Position Category", "Work Location", "Salary Range", "Education Requirements", "Experience Requirements", and so on.

By precisely defining the content model, AnQiCMS enables the website to better organize and present information, not only improving the efficiency of content management, but also providing users with more accurate and personalized browsing experiences.

Summary

The AnQiCMS content model customization feature is the foundation of its powerful flexibility.It gives website operators the ability to deeply customize the content structure according to actual business needs.From easily creating and configuring dedicated fields in the background to flexibly displaying these data through rich template tags on the front end, AnQiCMS provides a complete and easy-to-use solution.This means that, whether it is dealing with complex and varied content types, or pursuing the ultimate personalized display effects, AnQiCMS can be your reliable assistant, making your website content management agile and vibrant.

Frequently Asked Questions (FAQ)

  1. Ask: Will the previous articles and product data be affected after customizing the content model?Answer: When adding a custom content model, it will not affect existing article and product data.Please note that if you modify an existing model (such as an article model or product model) and delete any existing custom fields, the data corresponding to those fields may be lost.Therefore, before making structural modifications to the existing model, it is recommended that you proceed with caution or make a data backup.
  2. Ask: How can filtering and sorting be performed on the front-end page based on the values of custom fields?Answer: AnQiCMS providesarchiveFiltersLabels can be generated according to custom fields on the document list page or model homepage to create filtering conditions, which is convenient for users to filter in multiple dimensions. As for sorting,archiveListTags also supportorderThe parameter can be sorted by document ID, views, etc., and if you need to sort by a custom field, you may need to combine secondary development or use the advanced configuration capabilities of AnQiCMS.
  3. Ask: Does the custom field support multilingual?Answer: Custom fields are inherently bound to the content. AnQiCMS supports multilingual content, which means you can provide content for each