AnQiCMS deeply understands the importance of content diversity, and therefore provides powerful content model customization features, which is the core of solving such problems.Through flexible content models, we can create dedicated data structures for different types of content based on actual business needs, thereby achieving personalized and efficient content management and presentation.
Understanding the Content Model: The Foundation of Content Structure
The content model, in simple terms, defines a set of rules that includes which fields a certain content type contains, what types these fields are, and how they are managed in the backend.AnQiCMS is pre-installed with two common content models, 'Article Model' and 'Product Model', which provide basic field structures for articles and products.However, the requirements for website operation are far more than this, AnQiCMS allows us to create or modify custom content models on this basis, to meet various complex scenarios such as corporate websites, marketing sites, and product displays.
Custom content model: Flexible and customizable core
AnQiCMS's content model customization capability is one of its highlights.To start customization, we can go to the 'Content Management' module in the backend, 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 needs.
When creating or modifying content models, we need to pay attention to several key settings:
- Model nameThis is the display name of the model on the backend, 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 aliasEnglish for pseudo-static rules, determines the appearance of the model content 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
However, the true power of the content model is reflected in the "Custom fields of the content modelHere we allow us to add dedicated data fields for the model, just like adding different columns for different types of tables. The configuration options for custom fields are diverse:
- Parameter name:Field's Chinese display name, convenient for backend management and understanding, such as 'Author', 'Contact Number', 'Event Location'.
- Call fieldThis is the English name stored in the database for this field, which is also the unique identifier used when calling it in the template, for example
author/contactPhone/location. - field type:AnQiCMS provides a variety of field types to meet the different data entry and display requirements:
- Single Line Text:Suitable for short text information, such as author name, product model.
- Number:Ensure that the input is a number, applicable to price, inventory, quantity, etc.
- Multi-line text:Applicable to longer input content, such as product descriptions, event introductions.
- Single selection:Provide preset options, the user can only select one, such as product color, size (small, medium, large).
- Multiple selection:Provide preset options, the user can select multiple, such as product features.
- Drop-down selection[en]Similar to single-choice options, presented in a dropdown menu form.
- For selection fields, we can also setDefault value. These default values will be available as optional items for users.
- Is required: This can enforce content publishers to fill in this field, avoiding data omission.
Content entry and combination with model fields
Once the content model and its custom fields are defined, they will take effect in 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 common title, content, thumbnail, and other fields, the 'Other Parameters' area will automatically display all the custom fields under the content model.The content editor only needs to fill in these fields as needed, greatly improving the structurization degree and input efficiency of the content.
Flexible calling and display in the template
Just defining fields in the background is not enough, the key is how to beautifully present these data on the front-end page.English powerful template tag system provides convenience.
- Association between template and model: The naming convention of AnQiCMS template files follows certain rules,
{模型table}/detail.htmlUsed to display the detail 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
moduleDetailThe label can retrieve detailed information of the current model or a specified model, such as model name, URL alias, etc. - Display custom fieldsIn the content detail page, we can use directly.
{{archive.调用字段名}}The form of calling the value of a custom field. For example, if a custom field is calledauthoryou can directly use{{archive.author}}Show the author. For custom fields that need to be displayed in a loop (such as an image group field)arcimages), you can use{% archiveDetail arcimages with name="arcimages" %}Combinefora loop to iterate and display. - Custom fields on the category page): Similarly,
categoryDetailThe label also supports calling custom fields defined in the classification model, whether it is direct access or throughextrasloop traversal, it can achieve customized display. - Advanced filtering feature:
archiveFiltersTags allow us to generate filtering conditions based on custom model fields, which is very practical for websites that require multi-dimensional search and filtering of content (such as real estate, recruitment, e-commerce, etc.).We can build complex filtering interfaces based on these custom fields, greatly enhancing the user experience. - Logic control and iteration: combined
ifLogical judgment tag andforLoop through tags, we can dynamically adjust the display of content based on whether a custom field exists, its type, or its value, and even nest 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 through{{archive.activityLocation}}To display the activity location, via{{archive.registrationFee}}To display 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 variable needs
Custom content models play a crucial role in a variety of website operation scenarios:
- E-commerce websites:In addition to the basic product information, you can customize fields such as 'size', 'color', 'material', 'brand', 'suitable population', and display them on the product detail page and in the list filter.
- Real estate agency website:Can customize fields such as 'House Type (apartment, villa, office building)', 'Layout (one room, two rooms, three rooms)', 'Area', 'Floor', 'Decorative Condition', and provide multi-dimensional search.
- News Portal/BlogIn addition to the article content, you can customize fields such as "Source", "Author's Introduction", "Recommended Reading", and "Special Topics".
- Event Registration Website:Customize fields such as “Activity Type”, “Start/End Time”, “Application Deadline”, “Organizer”, “Co-organizer”, etc.
- Recruitment WebsiteEnglish: Customize fields such as 'Position Category', 'Work Location', 'Salary Range', 'Education Requirements', 'Experience Requirements', etc.
By precisely defining the content model, AnQiCMS enables websites to better organize and present information, not only improving the efficiency of content management but also providing users with a more accurate and personalized browsing experience.
Summary
AnQiCMS's content model custom feature is the cornerstone of its strong flexibility.It enables website operators 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 frontend, AnQiCMS provides a complete and easy-to-use solution.This means that whether it is dealing with complex and changeable content types, or pursuing the ultimate personalized display effects, AnQiCMS can become your reliable assistant, making your website content management effortless and焕发新生.
Common Questions (FAQ)
- 问:自定义内容模型后,之前的文章和产品数据会受影响吗?Answer: When adding a custom content model, it will not affect the existing articles and product data.But please note that if you modify an existing model (such as an article model or a product model) and delete any existing custom fields, the data corresponding to these fields may be lost.Therefore, before making structural modifications to the existing model, it is recommended that you operate cautiously or back up the data.
- 问:如何在前端页面中,根据自定义字段的值进行筛选和排序?Answer: AnQiCMS provides
archiveFiltersLabels, which can be generated according to custom fields on the document list page or the model home page to facilitate users in generating filtering conditions, making it convenient for users to filter in multiple dimensions. As for sorting,archiveListLabels are supportedorderParameters can be sorted according to document ID, view count, etc. If sorting by a custom field is required, it may need to be combined with secondary development or utilize the advanced configuration capabilities of AnQiCMS. - 问:Custom field supports multilingual?答:自定义字段本身是与内容绑定在一起的。AnQiCMS 支持多语言内容,这意味着您可以为每个 English