AnQi CMS: Let the custom content model fields shine on the front end

When using AnQi CMS to manage website content, we often encounter the need: the standard content structure can no longer fully meet the display of specific information.For example, on a product page, in addition to the title and content, we may also need to display its "color options", "size range", or "stock status".At this time, the flexible content model and custom field function of Anq CMS are particularly important, as it allows us to expand the content attributes according to the uniqueness of our business.

Why are custom fields so important?

One of the core strengths of AnQi CMS is its 'flexible content model'.This means you can define exclusive data structures for different content types according to your business needs.This high degree of customization breaks the limitations of the traditional CMS fixed fields, making your website content management more in line with actual operations.

For example, if your website is selling products, then a product detail page should include information such as SKU, price, stock quantity, brand, material, and target audience, in addition to the product name, description, and images.By custom fields, you can add these unique properties to the product model, so that each product entry has complete and standardized information.This not only facilitates background management, but also provides a solid foundation for the refined display of the front-end page.

Creation and type overview of custom fields

Under the "Content ManagementIn the model editing interface, you can add exclusive custom fields for the model.

These fields are very rich, covering a wide range from simple text inputs to complex options, including:

  • Single-line text:Suitable for brief text information, such as product models, source of articles.
  • Number:Only numbers can be entered, suitable for prices, inventory, page views, and so on.
  • Multi-line text:Suitable for long text descriptions, such as product features, event rules, and supports rich text editor.
  • Single choice:Provide multiple options, but only one can be selected, such as 'Do you recommend?' or 'Status'.
  • Multiple selection:Provide multiple options, allow multiple selections, such as product "color options", "applicable seasons".
  • Dropdown selection:Looks similar to single choice, but presented in a dropdown menu on the front end.

Set each field's "parameter name" (for backend display) and "call field

Display the core method of custom field on the front-end page

AnQi CMS adopts a template engine syntax similar to Django, using double curly braces{{变量}}Output content through{% 标签 %}Implement logical control. For custom fields, we mainly obtain and display them in two ways: directly referencing specific fields, or traversing all custom fields.

1. Directly reference a single custom field value

If you know exactly which custom field to display, you can use it directlyarchiveDetailLabel to obtain.This tag is mainly used for the document detail page, it can obtain the detailed information of the current document, including all custom fields.You only need to specify the name of the custom field "call field".

Assuming you have added the following custom fields to the product model:

  • Product Model(Invocation