In today's rapidly changing digital world, website content is no longer just simple articles or product introductions.In order to accurately target users and improve conversion, we often need to tailor the display form and data structure of different types of content to fit.AnQiCMS (AnQi Content Management System) is well-versed in this, and the flexible content model function it provides is the powerful tool to solve this challenge.
Understanding the core value of the AnQiCMS content model
You may be running a corporate website, where you need to publish industry news, technical articles, and also showcase detailed product parameters and successful cases; or you may be a self-media creator, who needs to publish various contents such as event registration, course introduction, and daily blogs.If all this content is cramped into a fixed "article" or "product" template, not only will the publishing efficiency be low, but the front-end display will also be chaotic and disorganized, making it difficult to meet the refined needs of users.
This is the value of the content model.It is like designing a dedicated 'blueprint' for each type of content, specifying what fields it should contain and how the data should be stored.AnQiCMS provides this highly customizable capability, allowing you to create infinite possible content structures according to your business needs, thereby achieving personalized content display.This has greatly enhanced the flexibility of content management, and has also laid a solid foundation for the website's SEO optimization and user experience.
Create and modify content models manually
The AnQiCMS backend design is very intuitive, allowing you to easily manage and customize content models.
To start customization, you need to log in to the backend, find the "Content ManagementThe system is already built-in with 'Article Model' and 'Product Model', which are the most commonly used content types.You can choose to modify these built-in models, or create a brand new custom model according to your needs.
When creating or modifying a content model, there are several key settings that we need to pay attention to:
- Model nameThis is the Chinese name you give to the content model, such as "News Dynamic", "Service Case", "Project Display", etc., which will be displayed directly in the background management interface and the breadcrumb navigation on the front page.
- Model table nameThis is a very critical setting that determines the table name where the model's data is stored in the database, and it is also referenced in the template through this table name. Please make sure to useEnglish lowercase lettersEnsure that it is unique throughout the system, avoiding conflicts with other models or system tables.
- URL alias: Also needs to be usedEnglish lowercase lettersThis alias will affect the URL structure of the front-end page, especially when you enable the pseudo-static rules and use
{module}When a variable is involved, it comes into play. A clear, meaningful URL alias is helpful for SEO. - Title NameThis setting is very user-friendly, it will serve as the prompt text for the document title input box when publishing content.For example, if you created a "product model", you can set the title name to "product name", so that the operator will be clearer what to fill in when publishing the product.
The core of the custom content model lies in the "custom fields of the content model".This is where you define unique data properties for a specific content type.
- Parameter NameThis is the Chinese name displayed on the background management interface, which is convenient for you and your team members to understand the purpose of the field.
- Field invocationThis is the unique identifier you use when referencing this field in the front-end template.It must be in lowercase English letters.Clear and descriptive. This field name will directly determine how you obtain the corresponding data in the template.
- Field type: AnQiCMS provides various field types to meet different data entry requirements:
- Single-line text: Suitable for short text input, such as product models, article sources.
- Number: Designed for numeric data types, such as product prices, inventory quantities.
- Multi-line text: Used for longer text input, such as product descriptions, case details.
- Single choice: Provide predefined options, the user can only select one, such as the "recommended level" of the article (headline, recommended, ordinary).
- Multiple selections: Provide preset options, the user can select multiple, such as the color (red, blue, green) of the product.
- Drop-down selection: Similar to single selection, but presented in a dropdown menu, saving page space.
- Mandatory?: Can force users to fill in this field when publishing content.
- Default valueSet an initial value for the field, especially when selecting class fields, here you need to enter one option per line, and the system will automatically parse it.
By combining these fields, you can build any content structure you want.For example, add fields such as "author", "source", "publishing media", and others to the "news dynamic" model; add fields such as "brand", "model", "material", and "size" to the "product display" model.
Display custom content in the front-end template.
Customized the content model, the next step is to present these rich data vividly on the front page.AnQiCMS's template system uses syntax similar to Django, allowing you to easily render backend data to the frontend.
On the content detail page (such as the article detail page or product detail page), you can use{% archiveDetail %}Label to get the various fields of the current content.For the fields you customize in the content model, you can directly obtain them through their 'call field'.authorthe calling field of (author), and it can be displayed in the template like this:{% archiveDetail with name="author" %}.
If you want to traverse all custom fields more flexibly, or want to dynamically display these parameters,{% archiveParams %}The tag comes into play. This tag will return an array containing all custom fields, each withNameand (parameter name)Value(Value). This is very useful for a general way to display "product parameters" or "service features".
For example, added 'price' and 'stock' fields to the product model, as well as a 'features' multi-choice field. On the product detail page, you can display it like this:
`twig
<h1>{% archiveDetail with name="Title" %}</h1>
<p>价格:{% archiveDetail with name="price" %}</p>
<p>库存:{% archiveDetail with name="stock" %}</p>
<h2>产品特性:</h2>
<ul>
{% archiveParams params %} {# 获取所有自定义参数 #}
{% for item in params %}
{# 假设“产品特性”的调用字段是“features” #}
{% if item.FieldName == "features" %}
{% set feature_list = item.Value|split:"," %} {# 多