How to display the banner image and category content on the Anqi CMS category page?

Calendar 👁️ 52

As an experienced person who deeply understands the operation of AnQiCMS, I fully understand your desire to make the category page more attractive and able to effectively convey information.In Anqi CMS, the category page is not just a container for document lists, but also an important node for brand image display and user guidance.By cleverly displaying banner images and categorized content, you can significantly enhance user experience and the professionalism of the page.

Next, I will explain in detail how to implement the display of Banner images and the presentation of classified content on the Anqi CMS category page.

The importance of optimizing the category page.

The category page is the key path for users to browse the website structure and find specific content.A well-designed category page that can quickly attract user attention through visual guidance and an overview of information, and help them find the content they need.AnQi CMS provides flexible backend configuration and powerful template tags, allowing you to easily customize exclusive Banner images and detailed descriptions for each category, thus creating beautiful and practical category pages.

Configure Banner image and content for category in the background

First, we need to complete the configuration of the category information in the Anqi CMS backend management interface.This includes uploading the Banner image for the category page and filling in detailed category introduction content.

You need to navigate to the 'Content Management' under the 'Document Classification' module.Here, you can edit or create a new category. In the form for editing categories, you will see an option called "Banner Image".Here you can upload multiple images, usually used for carousel or displaying multiple related images.To ensure the page effect, it is recommended that you upload images of the same size so that the front-end template can display uniformly.

Immediately, in the "Category Content" field, you can enter or paste a detailed introduction, feature description, or any rich text information you wish to display to users.This editor supports a variety of text editing features, you can add illustrated introductions to categories as you edit document content.

In addition to the Banner image and category content, you can also set other parameters such as SEO title, keywords, custom URL, etc. as needed, which will help improve the search engine friendliness of the category page.

Display the Banner image and category content in the template

After completing the background configuration, the next step is to call and display this information in the frontend template.The Anqi CMS template system is very flexible, allowing you to specify custom templates for each category model even for specific categories.

Generally, the template files for category pages are located/template/{您的模板目录}/{模型table}/list.htmlOr more specifically,/template/{您的模板目录}/{模型table}/list-{分类ID}.html. If you want to customize the layout for a specific category, you can create a template file with the latter naming convention.

In these category templates, you will mainly usecategoryDetailTag to get the detailed information of the current category, including the Banner image and category content previously set in the background.

Display the category Banner image

Display the banner image you uploaded on the category page, you can usecategoryDetailLabel collaborationname="Images"The parameter will return an array containing all the Banner image URLs.You can loop through this array to display all images or only show the first image in the array as the main banner.

Here is a basic template code example demonstrating how to retrieve and display the category Banner image:

{% categoryDetail categoryImages with name="Images" %}
{% if categoryImages %} {# 检查是否有Banner图上传 #}
<div class="category-banner-slider">
  {% for item in categoryImages %}
  <img src="{{item}}" alt="{% categoryDetail with name="Title" %}" />
  {% endfor %}
</div>
{% else %}
{# 如果没有Banner图,可以显示一个默认图片或者不显示 #}
<img src="/static/images/default_banner.jpg" alt="默认分类Banner" />
{% endif %}

If you only need to display the first Banner image, you can handle it like this:

{% categoryDetail bannerImages with name="Images" %}
{% if bannerImages %}
  {% set pageBanner = bannerImages[0] %} {# 获取数组中的第一张图片URL #}
  <img src="{{pageBanner}}" alt="{% categoryDetail with name="Title" %}" />
{% else %}
<img src="/static/images/default_banner.jpg" alt="默认分类Banner" />
{% endif %}

Please note,altThe setting of properties is very important for SEO, we go through{% categoryDetail with name="Title" %}Dynamically obtain the category title as the alternative text for the image.

Display category content

To display the rich content you have written for the category in the background, you also need to usecategoryDetailtags, but this time to cooperate withname="Content"The parameter. Since the category content may contain HTML tags or Markdown syntax, we also need to use|safeA filter to ensure that content is rendered correctly as HTML and not as plain text. If your content uses Markdown, you can also go throughrender=trueThe parameter allows the system to automatically convert it to HTML.

The following is the template code for calling and displaying categorized content.

<div class="category-description">
  <h3>{% categoryDetail with name="Title" %}简介</h3>
  {% categoryDetail categoryContent with name="Content" render=true %}
  {{ categoryContent|safe }} {# 使用 |safe 过滤器确保HTML内容正确渲染 #}
</div>

By following these steps, you can flexibly display eye-catching banner images and informative category content on the Anqi CMS category page.This not only beautifies the page, but also effectively guides users, enhancing the overall professionalism and user satisfaction of the website.


Frequently Asked Questions (FAQ)

Ask: I have uploaded the Banner image and filled in the category content, but the front-end page does not display. What is the matter?

Answer:This situation usually has several possible causes. First, please check if your classification template file is correctly referenced.categoryDetailthe tags, andnamewhether the parameters are set asImagesandContentMake sure your template file is uploaded to the correct path, for example/template/{您的模板目录}/{模型table}/list.htmlorlist-{分类ID}.html)。Another, after modifying the template file in the background, sometimes you need to manually clear the AnQiCMS cache to ensure that the latest changes take effect. Finally, check what you are incategoryDetailDid the tag use correctly|safeFilter (for content) and whether it isImagescorrectly traversed or indexed the field.

Ask: Can I set different Banner images and content layouts for different categories?

Answer:Absolutely. AnQiCMS provides flexible template specification functionality. You can create independent template files for each specific category, named in the format of{模型table}/list-{分类ID}.html. For example, the article category with ID 5 can be createdarticle/list-5.htmlThe template allows you to design a unique Banner display and content layout for this specific category.In the background "Document Classification" editing page, you can also directly specify the "Classification Template" to be a custom template name, so that it can be applied to the current category or its subcategories.

Question: Will a long category content affect the page loading speed or layout?

Answer:The length of the category content can indeed affect page loading and visual effects.Although the Go language backend of AnQiCMS ensures efficient data processing, the long HTML content itself increases the page size.It is recommended that you keep the content concise and highlight the key points when editing the category content in the background.If the content is indeed very long, consider using CSS or JavaScript to implement an "expand/collapse" feature that allows users to selectively read long content, thus keeping the page neat and loading quickly.At the same time, optimizing the image size, ensuring that the Banner image file is small, is also a key factor in improving page performance.

Related articles

How to customize the AnQi CMS category template, can it be inherited for subcategories?

As an experienced website operator who is well-versed in the operation of AnQi CMS, I fully understand your concern about the customization of classification templates and their inheritance mechanism.In Anqi CMS, the category template is the core element that determines the display method of category page content. Flexible template configuration can greatly enhance the user experience and content management efficiency of the website. ### Deeply understand the customization of Anqi CMS category template and inheritance of subcategory In Anqi CMS, the category page plays an important role in organizing and presenting specific types of content.

2025-11-06

How to set the SEO title, keywords, and custom URL of the category, and what help does it bring to SEO?

As a website operator who deeply understands the operation of AnQiCMS, I know the importance of every detail configuration for website search engine optimization.Especially in the core of content organization - category management, accurately setting SEO titles, keywords, and custom URLs is not only the key to improving user experience, but also the foundation for search engines to better understand and capture website content.I will elaborate in detail on how to perform these category SEO configurations in AnQiCMS, as well as how they bring tangible SEO benefits to the website.###

2025-11-06

How to create and manage multi-level categories in AnQi CMS, and can each category only belong to one content model?

As an experienced CMS website operations manager for a security company, I fully understand the importance of content structure and management.The Anqi CMS has a clear and efficient design concept in handling categories and content models, ensuring the structuring of website content and data consistency.Now, let's discuss in detail how Anqi CMS creates and manages multi-level categories, as well as whether each category can only belong to one content model. ### Content Model: The Foundation of Flexible Content The content model in Anqi CMS is the core of defining the structure of website content.

2025-11-06

What is the difference between the document summary and the document content, will AnQi CMS automatically extract the summary?

As a website operator who is well-versed in the operation of AnQiCMS, I know that the accurate understanding and effective use of each content element is crucial for attracting and retaining users.In the AnQiCMS content management system, **Document Introduction** and **Document Content** are two core and interrelated parts, each performing different responsibilities, jointly forming the foundation of high-quality content. **Document Introduction: The First Impression of Content** A document introduction, as the name implies, is a concise summary of the article.It usually appears on the search results page, article list page

2025-11-06

Does the Anqi CMS document list support which filtering conditions, can it be filtered by content model or category?

As an experienced security CMS website operation personnel, I know that efficient content management and accurate presentation are crucial for attracting and retaining users.AnQi CMS provides flexible and powerful functions in content management, among which the document list filtering conditions are the tools we frequently use in daily operations. They can help us quickly locate the required content and display it according to different business needs.In AnQi CMS, the document list supports various filtering conditions to meet the complex needs of website content operations.These filtering functions are not only reflected in the background management interface

2025-11-06

How to use AnQi CMS for batch keyword replacement on the entire site, does it support regular expressions?

As a website manager who deeply understands the operation of AnQiCMS, I am well aware of the key role of content quality and management efficiency in the success of the website.In daily operations, we often need to manage and update a large amount of content on the website, and batch replacement of keywords or links is a common requirement.The AnQi CMS provides an efficient and flexible tool for this.

2025-11-06

How is the retention mechanism of the document recycle bin in AnQi CMS, can deleted documents be recovered?

As an experienced security CMS website operator, I am fully aware of the importance of content security and data recovery for any content management system.AnQi CMS was designed from the beginning to fully consider all possible situations that users may encounter in the content management process, especially the data protection mechanism after accidental deletion of documents.For the retention mechanism of the document recycle bin and the recovery of deleted documents, Anqi CMS provides a clear and efficient solution.In Anqi CMS, the document deletion operation is not an immediate physical destruction.When you perform single document deletion or batch deletion operations on the content management interface

2025-11-06

Can the built-in article and product models of AnQi CMS be modified?

As a website operator deeply involved in AnQiCMS, I fully understand your need for content management flexibility, especially when dealing with core content types such as articles and products.An efficient content management system, one of its core values is its ability to adapt to business changes.About whether the article and product model built-in in Anqi CMS can be modified, I can give you a clear and detailed answer.The Anqi CMS was designed from the outset to fully consider the personalized needs of enterprises and operation teams for content structure.

2025-11-06