How to create custom fields for different content models (such as articles, products) in AnQiCMS?
Good, as an experienced website operation expert, I am very willing to analyze the powerful functions and actual operations of the customized fields in AnQiCMS for you in depth.
In AnQiCMS, create custom fields for different content models: unlock the powerful engine of personalized content
In the era where content is king, the diversity and personalization of website content are crucial to attract and retain users.A great content management system (CMS) should never limit you to a fixed content structure.AnQiCMS is well-versed in this, and its 'flexible content model' function is precisely designed to grant operators such capabilitiesCreate custom fields for different content models (such as articles, products)Thus, make your website content management more skillful and unique.
Understand the content model: the foundation of all personalization.
In AnQiCMS, all the content on your website is organized around the 'content model'.The system is default built-in with the two core models of "Article Model" and "Product Model", which define the basic information structure of articles and products respectively.However, the business requirements in reality are much more complex. An industry analysis article may require 'analyst name', 'report source';And an e-commerce product may need additional information such as 'color options', 'size details', 'material description', etc., besides the usual 'price' and 'inventory'.At this time, a custom field is naturally created.
Custom fields allow you to add any data items you think are necessary based on the existing content model to accurately reflect the unique properties of your content.This greatly enhances the flexibility of content management, and also provides more possibilities for front-end display and SEO optimization.
How to create custom fields in AnQiCMS?
The process of creating custom fields is intuitive and efficient, let's go through it step by step:
First, log in to the AnQiCMS backend management interface, find the "Content Management" in the left navigation bar, and then click to enter the "Content Model".Here, you will see the list of all content models on the website, including built-in 'article model', 'product model', and other custom models you may have created.
Select the content model you want to edit by adding a custom field.For example, if you want to add more attributes to e-commerce products, click on "Product Model" to enter its details page.On this page, you will see a name calledCustom fields for content modelHere is the region. That's where we cast our magic.
Click the 'Add Field' button, and a new field configuration form will appear in front of you. Here, you need to fill in some key information:
Parameter name:This is the display name of the field, convenient for you to identify and operate in the background management, such as "author name", "product material", "release date", and so on.Suggest using clear and understandable Chinese names.
Call field:This is crucial! "Field name used" is the actual field name stored in the database, as well as the unique identifier used when calling this data in the template.Please make sure to useEnglish lettersAs a field name, do not include spaces. For example, "Author Name" can be set to
authorName,"Product Material" can be set tomaterial. Remember this name, it will be the 'key' to retrieve data in the template.Field type:AnQiCMS provides various field types to meet different data storage needs.
- Single-line text:Suitable for storing brief string information, such as the author's name of an article or the brand of a product.
- Number:Designed specifically for numbers, like a product's 'price' or 'stock quantity' is very appropriate.
- Multi-line text:As the name implies, it is used to input longer text content, such as a product's 'detailed features description' or an article's 'additional summary'.
- Single choice, multiple choice, dropdown choice:These three types are suitable for providing preset options for users to choose from.For example, set the 'Color' option for the product (red, blue, green), and you can choose whether it is single selection or multiple selection.When selecting these types, you need to enter an option in the "Default Value" area on each line, and the system will automatically parse it as an optional item.
Mandatory?:Check according to business requirements. If this field is a mandatory item for content publication, please check this box. The system will verify it when submitted.
Default:If this field has a commonly used value at content creation, it can be preset here. For selection-type fields, this is used to define all optional items.
Configure the field and click "OK" to save. You can add any number of custom fields to the same content model as needed.
Use custom fields when publishing content
After you complete the creation of custom fields and associate them with a content model, these fields will dynamically appear when you publish or edit content that belongs to the content model.For example, when you add an article or product under "Content Management", in the "Other Parameters" collapsible box of the form, you will find the custom field you just defined listed there.
It is worth mentioning that AnQiCMS's dynamic adaptability is very intelligent.If you define 'author name' for the 'article model' and 'material' for the 'product model', only the 'author name' field will be displayed when publishing the article;When releasing the product, the 'Product Material' field will be displayed.This design of dynamically switching fields based on the content model greatly simplifies the background operations and avoids unnecessary confusion.
Display custom fields in the front-end template
The value of the custom field is ultimately reflected in the front-end display. AnQiCMS provides flexible template tags, allowing you to easily present these custom data on the website page.The name you set when creating the field, which is the key to your interaction with the template.
Assuming you have added a namedmaterial(Called field) custom field named “Product Material”:
Method one: go through directlyarchiveObject calling (for known field names)
In the product details page template, you can directly access througharchive(or a custom document variable name) object to access this field:
<!-- 产品材质 -->
<div>
<span>产品材质:</span>
<span>{{ archive.material }}</span>
</div>
Method two: usearchiveDetailLabel call (for retrieving specific fields)
Also can be usedarchiveDetailLabel to get the value of a specific custom field:
<!-- 产品材质 -->
<div>
<span>产品材质:</span>
{% archiveDetail productMaterial with name="material" %}
<span>{{ productMaterial }}</span>
</div>
Method three: usearchiveParamsLabel to iterate through all custom fields (for dynamic display)
If you want to dynamically display all custom fields and their values under a content model (for example, generating a 'product parameters' table on a product details page),archiveParamsThe label will be your **choice.
<!-- 产品参数列表 -->
<div class="product-params">
<h3>产品参数</h3>
<ul>
{% archiveParams params %}
{% for item in params %}
<li>
<span>{{ item.Name }}:</span>
<span>{{ item.Value }}</span>
</li>
{% endfor %}
{% endarchiveParams %}
</ul>
</div>
Through these methods, you can flexibly render custom field data to the page according to the needs of the frontend design, whether it is simple text display, complex option listings, or rich media content such as images, links, and so on.
Summary
AnQiCMS' custom field function is a vivid manifestation of its 'flexible content model' concept.It empowers website operators with strong content shaping capabilities, allowing you to no longer be limited by fixed content structures, and to adjust and expand the properties of content according to the evolution of business development and content strategies.In order to better organize information, improve user experience, or for more refined SEO layout, custom fields are an indispensable tool in your website operation toolbox.
Master and make good use of the custom fields of AnQiCMS, you will be able to build a truly tailored, dynamic personalized website that will give wings to your content marketing and user growth.
Frequently Asked Questions (FAQ)
1. If I call a custom field in a template by using the field name (for examplearchive.myCustomField), what will happen if I spell it wrong?Answer: If the field name called is spelled incorrectly or does not match the "field name called" set in the background, the template parsing will display blank or an error when it cannot find the corresponding data (depending on your template