The 'AnQi CMS' provides a very powerful core function in content management, that is, its 'flexible content model'.This not only allows us to publish traditional articles and product information, but more importantly, it gives us the ability to customize any content structure and display these contents on the website front-end in the way we want.
Understand the core value of flexible content models
In traditional CMS systems, we are often limited by predefined content types, such as being able to publish only '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 room types, area, geographical location, surrounding facilities, and other specific fields; if you manage an event registration platform, you may need 'event' content that includes event time, location, registration limit, and speaker, etc.
The flexible content model of AnQi CMS is designed to address this pain point.It allows us to break out of the inherent framework of "articles" and "products", and create completely customized content structures 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. The system can support them flexibly, thus greatly enhancing the management efficiency of content and the adaptability of the website.
Create your exclusive content model
To start 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 defaults to providing 'Article Model' and 'Product Model', but the real strength lies in your ability to create brand new models based on your own business logic.
When creating a new model, you need to set some basic information, such as the model's "name" (for example, "property", "event"), and the "model table name" (used for database storage, it is recommended to use lowercase English letters, such ashouseoractivityand the "URL Alias" (used for pseudo-static URLs, also recommended to be in lowercase English).
The most important thing is to add "custom fields" to your model.This is the core manifestation of the model's flexibility.
- Single-line text/Multiline text:Suitable for short text descriptions or long introductions.
- Numbers:Applicable to pure numeric information such as price, quantity, area, etc.
- Single choice/multiple choice/dropdown selection:Applicable to preset options, such as the 'house type' (one-bedroom, two-bedroom) of real estate, and the 'difficulty level' (beginner, intermediate, advanced) of activities.You can set these options in the "default value".
By these fields, you can build a content structure that matches your business logic completely.For the 'Project' model, add fields such as 'House Type' (dropdown), 'Area' (number), 'Location' (single line text), and 'Facilities' (multiple choices).
Link content to 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 is determined for its model, all content under this category will follow the field structure of the model.
Next, when you add a document in the "Document Management" backend, select the category you just created and associated with a custom model, you will find that the content editing interface, in addition to the traditional fields such as title, content, and abstract, also includes all the fields you customized for this model in the "Other Parameters" section.Here, you can enter the corresponding data for each content.
Flexible display of custom content 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 frontend, it is necessary for us to flexibly use the template design function of Anqi CMS.The Anqi CMS adopts a syntax similar to Django template engine, making template creation both intuitive and powerful.
Template files are usually located in/templatedirectory, and named with.htmlas a suffix. Anqi CMS will automatically match the corresponding template file according to the URL structure, for example,{模型表名}/detail.htmlused for detail pages,{模型表名}/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 retrieve data from your custom content model, the key is to use the template tags provided by Anqi CMS.
Get standard field content:For fields that come with the model, such as title, content, link, etc., you can get them easily by
archiveDetailusing tags. For example, display the title on the property details page:<h1>{% archiveDetail with name="Title" %}</h1>Display the main content:<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 being output as plain text.Get the content of the custom field:This is the core to demonstrate the flexibility of the custom content model. Suppose you have defined a custom field named
户型with the calling field namehouseTypeYou can get and display it directly like this: `Room type: {% archiveDetail with name=“houseType” %}