In AnQiCMS (AnQiCMS), the custom content model plays a core role, directly determining the structure and display of front-end article content.For content operators, understanding and making good use of this feature is the key to realizing personalized website content, improving user experience, and operating efficiency.
I. Understanding Custom Content Models: The Foundation of Flexible Content Management
Traditional CMS systems may only provide the two fixed content types of "articles" and "pages", but in actual operation, websites often need to display more diverse content, such as product details, event information, case studies, job postings, etc.Each content has its unique properties and information composition. The customized content model of AnQi CMS is exactly to solve this pain point.
It allows us to create and define new content types based on business requirements, no longer restricted by predefined formats.For example, you can create a content model named "Product" instead of squeezing all product information into a regular "Article" model.Such, each content model is like a blueprint, clarifying which data fields the type of content should include, thus laying a solid foundation for the personalized display on the front end.
II. Configuration of Model Fields and Content Entry: Defining the Display "Skelet
In the Anqi CMS backend management system, when creating or modifying a custom content model, we need to configure a series of exclusive fields for it.These fields are like the 'skeleton' of the content, determining the table for content entry and the data points displayed on the front end.
We can flexibly add various types of custom fields to meet the needs of different information storage:
- Single-line text or multi-line text:Suitable for short titles, summaries, product descriptions, event details, etc.
- Numeric type:Used for data that requires numerical calculations such as prices, inventory quantities, participant numbers, ratings, etc.
- Single choice, multiple choice or dropdown selection:Used for preset categories or tags, such as product color, event type, house type, etc., for convenient content standardization and front-end filtering.
- Image/Upload File:Allow uploading product image sets, event posters, attachment downloads, etc.
When we publish content in the background, we will first select a category, and each category is associated with a specific content model.Once a category is selected, the editing interface will dynamically display the corresponding custom fields based on the definition of the content model.For example, if you select a category under the "Product" model, fields such as "Price", "Inventory", "Brand", etc. will appear for content editors to fill in.These meticulously organized and entered data are the raw materials for the rich and personalized display of the front-end page.
III. The 'Magic' of Front-end Templates: Transforming Data into Visual Experience
AnQi CMS uses a template engine similar to Django, through{{变量}}and{% 标签 %}The syntax is used to parse and display data. The value of the custom content model lies in the fact that it allows template developers to precisely control the presentation of these custom fields on the front-end page.
Get standard fields and custom fields: accurately locate contentFor each content item (usually through
archiverepresented as an object), its built-in standard fields such as title ({{archive.Title}}), content ({{archive.Content|safe}}),and thumbnail ({{archive.Thumb}})Can be directly accessed using double curly brace syntax. Custom field calls are more flexible.Assuming we define a field named "Material" in the "Product" model (the field name used is calledmaterial) custom field, in the product detail page template, we can use{% archiveDetail with name="material" %}such tags to retrieve and display its content. If you are used to accessing object properties directly, you can also use{{archive.material}}The premise is that the template context containsarchiveThe object already contains this custom field. In this way, we can accurately display the product's material information at the specified location on the page.Traversal and dynamic display: dealing with complex data structuresCustom fields sometimes need to store more complex data, such as a product may have multiple display images, or an event may have multiple time periods.At this time, the template engine of Anqi CMS provides powerful iteration capabilities.For example, if the product model has a name called
arcimages(Group photo) custom field, stores multiple image URLs, we can display it in the template like this: `twig {% archiveDetail arcimages with name=“arcimages” %}- {% for img_url in arcimages %}