How to control the display of different content models (such as articles, products) on the front end?

Calendar 👁️ 72

In AnQi CMS, flexibly controlling the display methods of different content models (such as articles, products, cases, etc.) on the website's frontend is the key to improving user experience and meeting diverse business needs.The system provides a powerful and easy-to-understand mechanism that allows you to design and manage the display effects of the page in fine detail according to the content type and specific needs.

Understanding the basic role of content models

Firstly, we need to understand the core status of the content model in the Anqi CMS.The content model does not only define the structure of the content but also determines which data you can collect for different types of content.When you create or edit a content model, such as an 'article' model or a 'product' model, you can customize a series of fields, such as the 'author' or 'source' of an article, or the 'price', 'inventory', and 'color options' of a product.These custom fields are the foundation for displaying personalized content on the front end, and they will become the unique data you call and present in the template.These fields make "article" more than just a title and content, and also give "product" rich attribute details.

Implementing frontend display diversity through templates

The AnQi CMS uses a template engine similar to Django, allowing you to fully control the layout and content display of the page through HTML files and specific tag syntax.

  • Model-level template customization:The system has preset default display templates for each content model. For example, all articles will usually usearticle/detail.htmlAs the detail page template, all products will useproduct/detail.htmlSimilarly, the list page also has corresponding{模型table}/list.htmlThese are general templates at the model level, providing a unified display framework for all content under the model.You can edit these default templates to set the overall visual style for your articles or products.

  • Categorization template refinement:When you want different categories under the same model to have different display styles, Anqicms provides the category template feature.When editing a category, you can specify a 'category template' (for the list page of the category) and/or a 'document template' (for all content detail pages under the category).For example, articles under the 'News and Information' category can use a different detail template than those under the 'Technical Articles' category.Further, you can also choose to apply the category template settings to all subcategories, thereby simplifying management.

  • Single document template coverage:For certain special content that requires unique display effects, the system also provides ultimate flexibility.When publishing or editing a specific document (whether an article or a product), you can specify a "document template" for it separately.This template takes precedence over model-level and category-level templates, ensuring that the document is presented in the manner you specified.This is very useful when it is necessary to highlight a product or publish a special announcement.

  • Using custom fields to control display:The core of personalized display lies in how to effectively utilize the custom fields defined in the content model.For example, a "product" model may include fields such as "product size", "material", and "target audience", while an "article" model may include fields such as "reading time" and "recommendation level".These field values can be directly called in the template and their content can be used for conditional judgments to achieve dynamic page layout.For example, if a product has a promotional price, the template can determine whether the 'Promotional Price' field exists and decide whether to display the 'Original Price' and add a strikethrough accordingly.

Accurately call and render content in the template

In the actual template file, you will use various template tags and filters provided by Anqi CMS to retrieve and process content data:

  • Retrieve content details:UsearchiveDetailThe tag can retrieve detailed information about the current page or specified ID content, including the title, text, thumbnail, and most importantly - various custom fields. For example,{% archiveDetail with name="Title" %}It will display the current document title, while{% archiveDetail with name="price" %}it may show the price of the product (if your product model haspricethis custom field).

  • Loop through custom parameters:For complex custom fields in the content model (such as multiple choice, dropdown selections), or when you need to iterate through all custom fields to dynamically generate tables or lists,archiveParamsTags are particularly important. They can retrieve all custom parameters of a specified document and allow you toforloop through them one by one to display their names and values.

  • Display the content list: archiveListTags are a powerful tool for building list pages. They support fetching content lists by model, category, recommended attributes, sorting methods, and more, and can be combined with pagination tags.paginationImplement a comprehensive list display function.

  • Logical control and data processing: ifTags are used for conditional judgments, such as determining whether a custom field has a value before deciding whether to display it;forThe tag is used for looping through lists or arrays. Also, don't forget to use various practical filters, such assafeUsed for safely outputting HTML contentthumbUsed for getting image thumbnailsstampToDateUsed to format timestamps as wellrenderUsed to render Markdown content into HTML, which can help you better format and present data.

Through the above multi-level template configuration and powerful template tag functions, AnQi CMS ensures that you can create a unique and highly customized front-end display effect according to any content model, category, or even the specific needs of a single piece of content.


Frequently Asked Questions (FAQ)

  1. How to set up different list page layouts for the 'Phone' category and the 'Computer' category under the 'Product' model?Answer: You can edit the categories 'Mobile' and 'Computer' separately in the 'Content Management' -> 'Document Category' section of the backend. In the category editing interface, find the 'Category Template' option, and specify different template files for them, for exampleproduct/list-phone.htmlandproduct/list-computer.htmlThis way, when users visit these categories, the system will load the corresponding templates to render the list page.

  2. Ask: My 'article' model has a custom field called 'recommendation index', and only when the recommendation index is greater than 5, will a 'hot recommendation' indicator be displayed below the title on the article detail page. Can this be done?Yes, it is absolutely possible. First, make sure that the 'article' model has set the 'recommendation index' as a numeric custom field. Then in your article detail template (such asarticle/detail.htmlIn it, you can usearchiveDetailLabel gets the value of this field and combines itifLogical judgment controls the display. The code might look something like this:{% archiveDetail recommendIndex with name="推荐指数" %}, then{% if recommendIndex > 5 %}<span>热门推荐</span>{% endif %}.

  3. Ask: I have created a content model named "Service" and also added content, but the front-end page shows a blank or error when accessed. How should I troubleshoot?Answer: This is usually due to the lack of the corresponding model-level template file.After you create a content model, you need to create default detail page and list page template files for it.For example, if your model table name isservicePlease,templateCreate in the directoryservice/detail.htmlandservice/list.htmlFile, and ensure that these files contain the basic calling tags of the model content.If there are still issues, check whether the new model's URL rules are correctly configured in the background "pseudo-static rules".

Related articles

How to customize the display layout of the article detail page in AnQiCMS?

In website operation, the article detail page is not just a carrier of content, but also a key link for brand image, user experience, and SEO effect.A well-designed and logically organized detail page that can effectively increase user reading time, reduce bounce rate, and help search engines better understand and crawl content.For friends using AnQiCMS, deeply customizing the display layout of the article detail page is actually more flexible and convenient than you imagine.AnQiCMS as an efficient content management system, deeply understands the needs of content operators

2025-11-09

How to display user group (VIP system) information in AnQiCMS to support member level display?

In today's internet world, the member system of websites and user grouping functions have become increasingly common. It not only helps operators provide differentiated services, but also is an important means to realize content monetization and enhance user stickiness.AnQi CMS knows this, therefore it has built a powerful user group management and VIP system, allowing the website to flexibly provide customized content and permissions for different user groups.How can we clearly display user group information (that is, VIP level) on the front-end page of a website built with Anqi CMS?This is actually more direct than imagined

2025-11-09

How to use the `lorem` tag to generate placeholder text in the early stages of development, and quickly preview the display effect of the template?

At the early stage of website template development, designers and developers often face a common challenge: how to effectively preview and adjust the layout, style, and responsive performance of the template without real content?If each modification requires manual input of a large amount of text to test the effect, it will undoubtedly greatly reduce development efficiency.AnQi CMS knows this pain point and provides a very convenient and efficient built-in tag called `lorem`, which can help us quickly generate placeholder text during the development stage, so that we can focus on the visual presentation of the template itself.### `lorem`

2025-11-09

How to display the navigation list configured in AnQi CMS and support multi-level dropdown menus?

The website navigation acts as a 'compass' for users visiting the website, and its clarity and ease of use directly affect user experience and the efficiency of information acquisition.For a corporate website, a well-structured navigation system that supports multi-level dropdowns is essential.AnQiCMS (AnQiCMS) understands this and provides an intuitive and powerful backend configuration function, allowing you to easily build a navigation menu with a sense of hierarchy.Next, we will explore how to configure the navigation list in the Anqi CMS backend and make it perfectly present multi-level dropdown effects on the front end.--- ### Step 1

2025-11-09

How to independently configure content display templates for each site under multi-site management?

In the AnQi CMS multi-site management system, configuring a dedicated content display template for each site is the key to achieving brand differentiation, optimizing user experience, and meeting specific content display needs.AnQi CMS, with its flexible architectural design, provides various ways to achieve this goal, whether it is from the perspective of the entire site or refined to a specific content type, it can be highly customized. ### Understanding AnQi CMS Template Mechanism Firstly, we need to understand how AnQi CMS organizes and manages templates.All sites share a core template management area

2025-11-09

How to display thumbnails, titles, and summaries in the article list?

In website operation, how to display the content list efficiently and beautifully is the key to attracting users and increasing the number of visits.A clear display of a thumbnail, title, and introduction of an article list, not only can it help visitors find the content they are interested in at a glance, but it can also effectively improve the website's performance in search engines.AnQiCMS provides rich features and a flexible template system, allowing us to easily achieve such effects.How is the content of the article managed in the AnQiCMS backend?Display thumbnails, titles, and summaries in the article list

2025-11-09

How to filter and display a list of specific content based on recommendation attributes (such as "Headline

When operating a website, we often need to highlight certain important or recommended content, such as placing the latest news at the "top" or marking popular products as "recommended".AnQiCMS provides a flexible recommendation feature that allows you to easily filter and display these specific contents, thereby better guiding users to browse and enhance the value of the content. ### Understanding Recommendation Attributes and Their Functions The recommendation attributes in AnQiCMS can be considered as a special tag for content, used to mark its importance and display method on the website.These properties are rich in variety, for example: *

2025-11-09

What device adaptation modes does AnQiCMS support to optimize content display?

With the popularization of mobile internet, the types of devices used by users to access websites are becoming increasingly diverse, ranging from large-screen PC monitors to compact smartphones. The display effect of website content is directly related to user experience and the effective transmission of information.AnQiCMS is well-versed in this field, providing a variety of device adaptation modes to help users flexibly optimize content display and ensure that the website presents a**status**on any device.The device adaptation strategy of AnQi CMS is mainly divided into three types, each mode has its unique implementation method and applicable scenario

2025-11-09