AnQi CMS provides a very powerful core feature in content management, that is, its 'flexible content model'.This is not just about allowing us to publish traditional articles and product information, but more importantly, it gives us the ability to customize any content structure and display it in the way we want on the website front-end.
Understand the core value of the flexible content model
In traditional CMS, we are often limited by predefined content types, such as only being able to publish "articles" and "products", which seems inadequate when facing diverse business needs.For example, if you operate a real estate information website, you may need to publish 'project details', which includes floor plans, area, location, surrounding facilities, and other specific fields;If you manage a registration platform for events, you may need to create 'event' content, including event time, location, maximum number of participants, speaker, etc.
The flexible content model of AnQi CMS is designed to solve this pain point.It allows us to break out of the inherent framework of 'articles' and 'products', creating a completely customized content structure based on actual business needs.This means we can define the fields required for each content type, whether it's text, numbers, single-choice, multiple-choice, or image groups, allowing the system to flexibly support this, thereby greatly enhancing the efficiency of content management and the adaptability of the website.
Create your exclusive content model
To begin customizing the display structure of front-end content, the first step is to create or modify the content model.You can find the 'Content Model' option under the 'Content Management' menu in the Anqi CMS backend.The system provides the default "Article Model" and "Product Model", but the real strength lies in the ability to create completely new models based on your business logic.
When creating a new model, you need to set some basic information, such as the model's "name" (for example, "real estate", "event"), and the model table name (used for database storage, it is recommended to use English lowercase letters, such ashouseoractivity) and "URL alias" (used for static URLs, also recommended in lowercase English).
The most important thing is to add a 'custom field' to your model.This is the core embodiment of the flexibility of the model. Anqi CMS provides a variety of field types to meet the vast majority of content needs:
- Single-line text/multiline text:Suitable for short text descriptions or long introductions.
- Number:Applicable to pure numeric information such as price, quantity, and area.
- Single choice/Multiple choice/Dropdown choice:Applicable to preset options, such as the 'type' of property (one-bedroom, two-bedroom), and the 'difficulty level' of activities (beginner, intermediate, advanced).You can set these options in the "Default Value".
By these fields, you can build a content structure that matches your business logic.For example, add fields such as 'house type' (drop-down selection), 'area' (numeric), 'geographical location' (single-line text), 'facilities' (multiple choices), and others to the 'real estate' model.
Associate content with model
After creating the content model, you need to associate it with actual content through "Document Classification".When creating a new category or editing an existing category, you will find that you can select the "document model" to which the category belongs.Once the category determines its associated model, all content under this category will follow the field structure of the model.
Next, when you add a document in the "Document Management" section of the backend, select the category you just created and associated with the custom model, you will find that the content editing interface, in addition to the traditional title, content, summary, etc., in the "Other Parameters" section, you will see all the fields you have customized for the model.Here, you can enter the corresponding data for each article.
Display custom content flexibly on the front end
The content model defines the structure and storage of data, and in order to elegantly present these structured data on the website front-end, it is necessary for us to flexibly use the template design function of Anqi CMS.AnQi CMS adopts syntax similar to Django template engine, making template creation both intuitive and powerful.
Template files are usually located/templatethe directory, and.htmlas a suffix. Anqi CMS will automatically match the corresponding template file according to the URL structure, for example{模型表名}/detail.htmlfor the detail page,{模型表名}/list.htmlUsed for list pages. Of course, you can also specify a custom template file path for specific content in the category or single page settings in the background, such as specifying for the "About Us" page.page/about.html.
To obtain data from your custom content model, the key is to use the template tags provided by Anqi CMS.
Get standard field content:For fields built into the model, such as titles, content, links, etc., you can easily obtain them through
archiveDetailtags. For example, the title displayed on the real estate detail page is:<h1>{% archiveDetail with name="Title" %}</h1>Display the text:<div>{% archiveDetail with name="Content" %}{{archiveDetailContent|safe}}</div>Here|safeThe filter is very important, it ensures that the HTML content entered in the rich text editor can be normally parsed and displayed by the browser, rather than output as plain text.Get custom field content:This is the core of demonstrating the flexibility of a custom content model. Suppose you define a custom field named
户型in the 'Real Estate' model, and its calling field name ishouseTypeYou can get and display it directly: `Room type: {% archiveDetail with name=“houseType” %}