How to display the Banner or carousel image for a category on the category page?

Calendar 👁️ 79

In website operation, the category page is an important entry for users to browse content and understand the website structure.A visually appealing, clear-themed category page banner image or carousel, which can significantly improve user experience, strengthen brand image, and effectively guide users to explore more content.AnQiCMS as an efficient and flexible content management system provides a very convenient way to display these images on category pages.

This article will elaborate on how to add a dedicated Banner image or slideshow to your category page in AnQiCMS from two aspects: backend settings and frontend template calls.


The first step: Set the Banner image for categories in the background

One of the design philosophies of AnQiCMS is its high degree of customization, and setting a Banner image for categories is a manifestation of this advantage.

First, please log in to your AnQiCMS backend management interface. Navigate to the left menu'sContent ManagementSelect thenDocument Category. Here, you can see the list of all content categories on the website.

Find the specific category you want to set the Banner. You can click on the category on the right side of the “EditModify the button or, if you are creating a new category, you can also complete the settings in the process of adding the category.

At the bottom of the category editing page, you will find a collapsible area named “.. Expand this area to see a named “Banner imageThe settings item. This is the key position for uploading and managing category Banner images.

You can upload one or more images as needed. AnQiCMS supports uploading multiple images as a carousel, and the system will automatically recognize them as a collection of images for that category.To ensure the beauty and consistency of the front-end page, I strongly recommend that you upload images of the same size and proportion.After uploading, don't forget to click on the link below the pageConfirmButton to save your changes.


Step two: Call and display the Banner image in the front-end template

The upload of the background images has been completed, next we will let these images 'shine' on the classification page of the website's front end.The AnQiCMS template system uses syntax similar to Django, which is very intuitive.

Generally, the template files of the category page are stored in the template directory you are currently using{模型table}/list.html(For example,)article/list.htmlorproduct/list.html),or you may have already specified a custom template file for this category.Please find the appropriate location in your template file and add the following code snippet to call the Banner image.

We will mainly use{% categoryDetail %}This tag is used to obtain the detailed information of the current category, which includes the banner image data we uploaded.

1. Call multiple images to implement a carousel effect

If you upload multiple Banner images for categories in the background and want to implement a carousel display on the front end, you can call it like this:

{# 获取当前分类的Banner图片列表 #}
{% categoryDetail categoryImages with name="Images" %}
{% if categoryImages %} {# 检查是否有图片上传,避免空内容 #}
<div class="category-banner-carousel">
    {# 这里可以集成您的前端轮播插件所需的HTML结构,例如Swiper或Owl Carousel #}
    <div class="swiper-wrapper">
        {% for imageUrl in categoryImages %}
        <div class="swiper-slide">
            <img src="{{ imageUrl }}" alt="{% categoryDetail with name='Title' %}" class="img-fluid" />
        </div>
        {% endfor %}
    </div>
    {# 如果需要,可以添加轮播的导航、分页器等控制元素 #}
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
    <div class="swiper-pagination"></div>
</div>
{% endif %}

In the code above:

  • {% categoryDetail categoryImages with name="Images" %}This line of code assigns the array of Banner image URLs for the current category tocategoryImagesVariable.
  • {% if categoryImages %}This is a conditional judgment to ensure that the related HTML is rendered only when the category has indeed uploaded the Banner image, to avoid blank pages or errors on the page.
  • {% for imageUrl in categoryImages %}:TraversecategoryImagesarray,imageUrlThe variable will sequentially obtain the URL of each image.
  • <img src="{{ imageUrl }}" alt="{% categoryDetail with name='Title' %}" class="img-fluid" />Output the image tag,altProperties used{% categoryDetail with name='Title' %}to dynamically obtain the current category title, which is very friendly to SEO.
  • Please note:in the above code snippet.swiper-wrapper/swiper-slide/swiper-button-prevThis is an example of the HTML structure for the Swiper carousel plugin.If you use another carousel plugin, replace it with the corresponding HTML structure of the plugin and make sure to include the corresponding CSS and JavaScript files.

2. Only display one Banner image (e.g., as the category header cover)

If you only need to display the first uploaded image as the cover of the category page, you can do it like this:

{# 获取当前分类的Banner图片列表,并只取第一张 #}
{% categoryDetail categoryImages with name="Images" %}
{% if categoryImages %}
{% set firstBanner = categoryImages[0] %} {# 使用set标签获取数组中的第一张图片 #}
<div class="category-single-banner">
    <img src="{{ firstBanner }}" alt="{% categoryDetail with name='Title' %}" class="img-fluid" />
    {# 您可以在图片上方或下方放置分类标题等 #}
    <h1>{% categoryDetail with name='Title' %}</h1>
</div>
{% endif %}

here,{% set firstBanner = categoryImages[0] %}BysetLabels willcategoryImagesAssign the URL of the first image in the array tofirstBannera variable, and then use this variable directly to display the image.

3. Display the Banner image as a background image.

Sometimes, you may want to use a Banner image as the background picture of a certain area on the page to achieve a more unique design effect. This is also very easy:

{# 将Banner图作为背景图片显示 #}
{% categoryDetail categoryImages with name="Images" %}
{% if categoryImages %}
{% set firstBanner = categoryImages[0] %}
<div class="category-hero-banner" style="background-image: url('{{ firstBanner }}'); background-size: cover; background-position: center; height: 300px;">
    {# 您可以在这里放置分类标题或其他内容,例如一个居中对齐的H1标题 #}
    <h1 class="text-center text-white">{% categoryDetail with name='Title' %}</h1>
</div>
{% endif %}

Here we will use the image URL as a CSSbackground-imageattribute value to apply. By adjustingheight/background-sizeetc CSS properties, you can flexibly control the display effect of the background image.


By using the above simple backend configuration and front-end template tag call, you can easily display exquisite banner images or slide shows on the AnQiCMS category page.This can make your website more visually appealing and effectively convey the classification theme, enhancing the user's browsing experience.


Frequently Asked Questions (FAQ)

1. Why did I upload a Banner image but it didn't display on the front page?When encountering this situation, please check two core points first:

  • Backend configuration:Confirm that you have logged in to the AnQiCMS backend, entered "Content Management" -> "Document Category" and edited the corresponding category, uploaded an image in the "Banner Image" area under "Other Parameters", and clicked the save button.
  • Template call:Check your classification template file (for examplearticle/list.htmlor the custom classification template you added) to see if the correct one was included{% categoryDetail %}tags have been added to the template file.Imagesfield

Related articles

How to display or hide certain content or features of a website based on user group permissions?

In website operation, displaying different content or functions based on the user's identity or permissions is a very common and important need.In order to provide exclusive benefits for VIP members, hide internal information, or customize operation interfaces based on user roles, precise content control can significantly improve user experience and website operation efficiency.AnQiCMS (AnQiCMS) with its flexible user group management and powerful template engine, can help us easily achieve this goal.###

2025-11-07

How to use the `flag` recommendation attribute to display recommended content in a specific area on the front page?

In website content operation, we often need to highlight certain specific content, such as the headline news on the homepage, special recommendations on product pages, or focus content on the carousel.To display this content flexibly in a specific area on the website front page, Anqi CMS provides a very practical feature: **Content Recommendation Attribute (Flag)**.This feature can help us manage the display logic of content more finely, filtering out some important or special-purpose content from a massive amount of information and presenting it in the place where users are most likely to notice.###

2025-11-07

How to embed dynamic contact information on the page, such as phone and address?

It is crucial to maintain the accuracy and consistency of contact information in website operation.This information, such as phone numbers, addresses, or social media links, often needs to be updated. Manually modifying each page not only takes time and effort but is also prone to errors.AnQiCMS (AnQiCMS) provides a very convenient way for you to dynamically manage and embed this contact information, achieving 'one-time modification, full-site update'. We will discuss in detail how to achieve this goal in Anqi CMS.### Centralized management of contact information on the backend First

2025-11-07

How to display the website's ICP record number and copyright information in AnQiCMS template?

In the operation of a website, the ICP filing number and copyright information are indispensable components for the legal operation and protection of the website's rights and interests.For websites operating in mainland China, the ICP record number is an explicit legal requirement. It not only guarantees the legality of the website but also enhances users' trust in the website.Copyright information specifies the ownership of the website content, helping to protect original works from infringement.

2025-11-07

How to implement different templates for displaying websites on PC and mobile endpoints?

How to ensure that your content is presented in a**state**on different devices is a crucial issue in website operation.With the popularity of mobile devices, the change in user habits requires that websites not only perform well on the PC side, but also provide a smooth and friendly experience on mobile devices.AnQiCMS (AnQiCMS) is well-versed in this field, providing us with flexible solutions, especially since it supports three main website modes: adaptive, code adaptation, and PC + mobile independent site mode, allowing us to use different templates for PC and mobile ends according to specific needs

2025-11-07

How to enable Webp format conversion in website content images to improve loading speed?

In website operation, image loading speed is one of the key factors affecting user experience and search engine ranking.The traditional JPG and PNG formats are widely used, but they are often less efficient in file size compared to some modern image formats.WebP is an advanced image format developed by Google that can significantly reduce the file size of images while maintaining image quality, thereby significantly improving the loading speed of web pages.For a content management system, if it can easily support WebP conversion, it will undoubtedly greatly reduce the optimizer's burden.

2025-11-07

How to automatically add image watermarks or anti-capture interference codes to front-end article content?

Protect originality, how can Anqi CMS automatically add watermarks and anti-crawling interference codes to your article content In the era where content is king, original content is the core competitiveness of a website.However, the arbitrary collection and misuse of content has become a pain point for many website operators.This violates copyright, may dilute the SEO value of original content, and even damage the brand image.Anqi CMS understands the value of content originality, therefore the system is built with powerful anti-crawling and watermark management functions to help you protect your intellectual property rights from the source

2025-11-07

How to display a list of friend links at the bottom of a website?

In website operation, friendship links are an important way to enhance website authority, increase external traffic, and enhance user trust.AnQiCMS (AnQiCMS) offers convenient features, allowing you to easily display these valuable external links at the bottom of your website. ### First Step: Add and Configure友情链接 in the Background Management Firstly, we need to add and manage友情链接 in the Anq CMS background management system.This is like the content list you prepare to display on the website.1. **Log in to the backend:** Log in to the AnQi CMS backend with your admin account

2025-11-07