Today, with the increasing refinement of content operation, the way websites display content is no longer just simple titles and text to meet all needs.Whether it is to display product detailed parameters, registration information for events, or record the professional backgrounds of team members, we need a more flexible and structured content management method.AnQiCMS (AnQi Content Management System) provides strong support in this aspect, through its 'custom field' feature, helping us easily expand content display options and create a highly personalized website experience.
Why does content display need more flexible options?
AnQiCMS deeply understands this requirement, its 'flexible content model' design is precisely to address the pain points of the rigid content structure of traditional CMS.It allows us to break out of the established frameworks of 'article' and 'product', defining a set of exclusive, customizable fields for each content type based on business logic. This makes the content more structured and provides endless possibilities for front-end display.
The content model and custom fields in AnQiCMS
In AnQiCMS, custom fields exist based on the 'Content Model'.The system preset 'Article Model' and 'Product Model' as two common models, but its core highlight is that we can completely create new content models or extend existing models.
Enter the 'Content Management' section of the AnQiCMS backend, find the 'Content Model' option, which is the core area for defining the content skeleton.We can see that each model has a series of basic attributes, such as model name, model table name (used for database storage), URL alias, etc.The real vitality of the content comes from the freely configurable "custom fields" under each model.
How to create and configure custom fields
The process of creating custom fields is very intuitive.When editing or creating a new content model, we can add exclusive fields to the model.
- Parameter name:This is the name displayed to the operator in the background management interface and while editing content, such as 'Product Color', 'Event Date', 'Author Position', etc. It should be clear and easy to understand.
- Field call:This is the unique identifier stored internally in the system and called in the template, it is usually recommended to use letters, such as
color/event_date/author_position. The template retrieves the corresponding data through this name. - Field Type:AnQiCMS provides various field types to meet different data format requirements:
- Single-line text:Suitable for brief text information, such as product models, one-sentence summaries.
- Numbers:Ensure that the input data is pure numbers, suitable for prices, inventory, quantities, etc.
- Multi-line text:Applicable to longer text descriptions, such as product features, author bios, etc., and can even combine Markdown editors to implement rich text content.
- Single choice, multiple choice, dropdown selection:
- Mandatory:Decide whether the user must fill in this field when publishing content, ensuring the completeness of key information.
- Default value:Provide preset values for the field, facilitating quick filling in by users or as a fallback if not filled in.
Apply Custom Fields in Content
Once the content model is defined and custom fields are added, these fields will be reflected on the background document (article, product, etc.) editing page.Generally, they appear in the 'Other Parameters' collapsible area for convenience in content editing.
When we are editing a 'product' content, in addition to filling in the title and main description, we will also see input boxes for custom fields such as 'product color' and 'product size'.The editor only needs to fill in the corresponding data according to the actual situation.This structured input method not only makes content management more organized, but also greatly improves the efficiency and accuracy of content publishing.
Flexible Display: How to Call Custom Fields in Templates
The value of the custom field is ultimately reflected in the flexible display on the front-end page.AnQiCMS uses a template engine syntax similar to Django, making it very convenient to call data of custom fields in templates.
For documents (archive) or categories (category) content, we can call custom fields in two main ways:
Directly call specific fields:If you know the name of the 'Invoked Field' custom field (for example,
author/price), you can use it directly,{% archiveDetail with name="author" %}or{{archive.author}}(ifarchiveTo obtain its value, use the variable (is the current content) to get it. This method is suitable for scenarios where you need to display a specific custom field precisely. For example, displaying the author's name of a blog post:<p>作者:{% archiveDetail with name="author" %}</p>Or display the product price on the product detail page:
<p>产品价格:¥ {% archiveDetail with name="price" %}</p>If a custom field is multi-line text and you want it to parse the Markdown format to HTML, you can combine
renderFilter:<div>作者简介:{% archiveDetail authorIntro with name="author_intro" %}{{ authorIntro|render|safe }}</div>Loop through all custom fields:When the content model has multiple custom fields and you want to dynamically display all parameters in a list or table format,
{% archiveParams %}Tags are very useful.It will return an array object containing all custom field names and values, which we can iterate over in the template.This is very efficient for generating product parameter lists or member information cards, no need to manually list each field.<div class="product-specs"> <h3>产品参数</h3> <ul> {% archiveParams params %} {% for item in params %} <li> <strong>{{item.Name}}:</strong> <span>{{item.Value}}</span> </li> {% endfor %} </ul> </div>This way, even if custom fields are added or deleted in the background, the front-end page can automatically adapt without modifying the template code.
In addition, AnQiCMS's custom field capability extends to the additional properties of the guestbook form and category, allowing for highly customizable interaction and display of these parts.
In summary, AnQiCMS's custom field feature brings unprecedented flexibility to content operations.It elevates content from simple text blocks to structured data sets, enabling websites to carry richer, more personalized information and present it in a way that better fits user habits and business needs.