How does the custom content model of AnQi CMS affect the display of front-end data fields?

Calendar 👁️ 70

In website content management, flexibility is the key to improving efficiency and user experience.AnQiCMS (AnQiCMS) performs well in this aspect, its custom content model function is particularly powerful.It not only makes content management more organized, but also directly affects the way front-end data is displayed on the website, allowing the website to easily adapt to various content structures and business needs.

Understanding the custom content model

One of the core strengths of Anqi CMS lies in its 'flexible content model'.This means, in addition to the built-in "article model" and "product model", users can create new content types based on their own business logic, such as "event model", "case model", or "talent recruitment model".Each custom content model can be considered as an independent content container, with its own unique field set, which is the basis for the data of the front-end page.

In the Anqi CMS backend, when we create a custom content model, we will define a series of fields, including:

  • Model name and URL aliasThis determines the display name of the content model in the background, as well as its appearance in the URL structure, for example,/cases/Or/activities/.
  • Title NameThis configuration item affects the prompt text of the 'Document Title' input box when content is published, making it clearer for content editors to determine whether they are entering an 'Event Name' or a 'Product Title', thereby indirectly improving the semantic accuracy of the front-end content.
  • Custom fields for content modelThis is the soul of the custom content model.It allows us to add unique data fields for each content model, and the type of these fields will directly determine the display method of the front-end data.

How custom fields affect the display of front-end data

Custom field types are diverse, each carrying different data representations, thereby presenting different effects on the frontend page:

  1. Single-line text (text) and numberThese fields are typically used to store brief text information or numbers, such as 'brand name', 'product model', 'price', 'inventory', etc.On the front end, they are often displayed directly or as a summary in a list.For example, a "product model" can have a "product model number" field, and the model information is displayed directly on the product details page.

  2. Multiline text (textarea): A multi-line text field carries more rich content, such as "event details", "product description", etc.Since it may contain HTML tags or Markdown syntax, it usually needs to be specially handled on the front end to ensure that it is correctly parsed as rich text content and presented with formatting, images, and other effects.

  3. Single choice (radio), multiple choice (checkbox), dropdown selection (select)These field types are used to set predefined options so that content editors can make choices from a limited set.On the front end, single selection is usually displayed with a single text or icon representing the selected value, while multiple selections may require iterating through all selected values to display them in the form of a list, tag cloud, or other forms.For example, a "product model" can have a "color

Besides the field type, other properties of the field will also affect the display on the front end:

  • Default value: If a field is left blank during content editing and the field has a default value set, then the default value will be displayed on the front end to ensure the integrity of the content.
  • Mandatory?This mainly affects the integrity of background content publishing, indirectly ensuring the availability of key information on the front-end page.

Flexible data calling through template tags.

The Anqi CMS adopts a template engine syntax similar to Django, which allows for easy presentation of data defined in the backend custom content model through concise template tags.

  1. Retrieve specific content data On the content details page, we can usearchiveDetailLabel to retrieve the various data of the current content, including custom fields. For example, if the product model has a custom fieldmaterial(material), then in the template, we can use{% archiveDetail with name="material" %}Come directly to display its value. Similarly,categoryDetailTags are also used to obtain detailed data of categories, including custom fields.

  2. Dynamically traverse custom fieldsSometimes, we may need to dynamically display all custom parameters of a content type on a page, such as the "specification parameters" list on a product detail page. At this point,archiveParamsThe tag comes in handy. It can traverse all custom fields of the current content, allowing us to render the names and values of these parameters uniformly in a loop, such as:

    {% archiveParams params %}
    {% for item in params %}
        <div><span>{{item.Name}}:</span><span>{{item.Value}}</span></div>
    {% endfor %}
    {% endarchiveParams %}
    

    This approach is particularly suitable when there are many custom fields, or when parameters need to be dynamically added or removed based on backend configuration.

  3. Combine conditional judgment and loop.The front-end display flexibility also lies in its ability to combineifLogical judgment andforLoop tags. For example, for custom fields with multiple choices, we can iterate over all selected values; if a custom field may be empty, we can useifCheck if it exists before displaying to avoid blank pages or errors. At the same time, for multi-line text content, to correctly parse the HTML that may be included, we usually use|safeFilter to ensure content is presented in HTML format rather than plain text.

Actual effect and user value

The tight integration of the custom content model with the front-end data display brings significant value to the user:

  • Highly customizableThe website is no longer limited to a fixed content structure. It can create new content types and fields at any time according to business development without modifying the underlying code.
  • Improve content operation efficiency: When content editors fill in information in the background, the field names and types are more closely aligned with the actual content, reducing the cost of understanding and errors.
  • optimize user experience:The front-end page can accurately display the required information according to the content type, designing a more targeted and attractive page layout.
  • SEO-friendlyTo create structured data fields for different types of content, it helps search engines better understand and index website content, thereby improving search rankings.

In summary, Anqi CMS's custom content model is not just a configuration item on the back end, but a bridge connecting the back-end content structure to the front-end visual presentation.By precisely defining field types and making good use of template tags, we can grant the website great content display freedom, truly realizing content-driven website operations.


Frequently Asked Questions (FAQ)

  1. Ask: How can the fields added to the custom content model be displayed on the front page?Answer: You need to use the template tags provided by Anqi CMS in the front-end template file to call these fields. For example, for the custom fields of the current content, you can use{% archiveDetail with name="您的自定义字段名" %}To retrieve and display the value of a specific field. To iterate over all custom fields, you can use{% archiveParams params %}{% for item in params %}{{item.Name}}: {{item.Value}}{% endfor %}{% endarchiveParams %}.

  2. Ask: If my custom field is the content entered in the rich text editor (which may contain HTML), will it display abnormally on the front end?Answer: Yes, if displayed directly, it may output HTML tags as plain text. To render these HTML contents correctly, you need to use the output field content in the template with|safea filter. For example:{{ archiveContent|safe }}or{{ item.Value|safe }}.

  3. Ask: Can I control the different styles or content displayed on the front page based on the value of a custom field?Of course, you can use the Anqi CMS template engine's{% if 条件 %}The tag to determine the value of a custom field, then display different content or apply different CSS styles based on the judgment. For example, if there is a custom fieldis_featured(Recommended), you can write in the template{% if archive.is_featured %} <span class="featured-badge">推荐</span> {% endif %}.

Related articles

How to use the recommended attributes of Anqi CMS (such as headlines, sliders) to control the display of homepage content?

When building and maintaining a website, the homepage is undoubtedly the first stop for users to visit, and its way of displaying content directly affects user experience and information communication efficiency.A meticulously planned and flexible homepage layout that can effectively attract visitors, guide traffic, and highlight the core value of the website.AnQiCMS provides a series of powerful content recommendation features, allowing you to easily control the dynamic display of homepage content and meet various operational needs.Flexible use of AnQi CMS recommended attributes AnQi CMS in content management

2025-11-09

How to extract and display the thumbnail and cover image of the document content in Anqi CMS?

In AnQi CMS, managing and displaying document content thumbnails and cover images is an important aspect for enhancing the visual effects of a website, optimizing user experience, and improving search engine friendliness.AnQiCMS provides a flexible mechanism to handle these image resources, whether they are automatically extracted from the content or manually uploaded and specified, they can be managed in detail in the background and called through simple template tags on the front end.

2025-11-09

How to ensure that the AnQi CMS website displays content normally on PC, mobile, or adaptive mode?

When building and operating a website, the display effect of content on different devices is crucial to the user experience.AnQiCMS provides a variety of mechanisms and rich features to help users easily cope with the challenges of content display on PC, mobile, and various adaptive scenarios.Understanding and appropriately utilizing these features can effectively ensure that your website content is presented normally and beautifully on any screen.--- ## One, understand the responsive and adaptation mechanism of AnQiCMS AnQiCMS provides flexible options in website modes

2025-11-09

How to set an independent display template for a specific page or content block in AnQi CMS?

In the daily operation of Anqi CMS, we often encounter such needs: certain pages or content need to break away from the unified style of the website and present in a unique way.This could be to highlight an important product, create a dedicated landing page for a special topic event, or simply make the "About Us" page more brand-specific.

2025-11-08

How to set the SEO display rules for article, product, page titles and other content in AnQi CMS?

In website operation, the content title is like the facade of the website, it is not only the first impression seen by visitors, but also an important basis for search engines to understand the content of the page and judge its relevance.A meticulously optimized content title that can significantly improve the click-through rate (CTR) and ranking of the website.AnQiCMS (AnQiCMS) as a highly SEO-friendly content management system, has provided us with very flexible and powerful tools to finely set the SEO display rules for articles, products, pages, and other content. Next

2025-11-09

How to implement flexible navigation menu and submenu display in AnQi CMS template?

In website operation, a clear and intuitive navigation menu is the core of user experience.It can not only help visitors quickly find the information they need, but it is also a direct embodiment of the structure and content organization logic of the website.AnQiCMS (AnQiCMS) leverages its efficient architecture based on the Go language and Django-style template engine to provide great flexibility for content creators and developers, enabling the display of various complex navigation menus and sub-menus.Implement flexible navigation menus and sub-menus in the AnQi CMS template

2025-11-09

How to display dynamic breadcrumb navigation and customize its display in Anqi CMS?

When we browse websites, we often see a line at the top or bottom of the page indicating the current navigation path, which is what we usually call 'Breadcrumbs'.It can not only clearly tell the user the position of the current page in the website structure, but also effectively improve the user experience and search engine optimization (SEO) effect of the website.AnQiCMS (AnQiCMS) is a powerful content management system that comes with a convenient way to generate and customize this dynamic breadcrumb navigation.

2025-11-09

How to display filter conditions on the document list page of Anqi CMS and dynamically update results based on parameters?

In AnQi CMS, adding filtering conditions to the document list page and dynamically updating the results based on user selection is an important aspect of improving the discoverability and user experience of website content.This not only helps visitors quickly locate the content they are interested in, but also has a positive impact on SEO through a clear URL structure.Let's understand step by step how to implement this feature in Anqi CMS. ### Core Function: Content Model and Custom Fields are Basic Everything in Anqi CMS is built based on the "Content Model". The filtering function on the document list page

2025-11-09