How to display a custom Banner image group on the category page or single page?

Calendar 👁️ 82

In website operation, the attractiveness of visual content is crucial.Especially for category pages and standalone single pages, displaying a set of carefully designed banner images can effectively attract visitors' attention, strengthen the brand image, and convey specific information.AnQiCMS provides a straightforward and flexible mechanism that allows you to easily configure and display custom Banner image groups on these key pages.

Understand the AnQiCMS Banner image mechanism

AnQiCMS considers the Banner image group of category pages and single pages as the property of the page itself.This means you can directly upload and manage them on each category or single page editing interface without relying on the global or independent Banner module.This design concept gives you a high degree of content customization freedom, ensuring that each page can have the most fitting visual presentation that aligns with its theme and marketing goals.You can upload multiple images to form a Banner carousel group or simply display a core image.

Set Banner images for category pages and single pages in the background

The operation to configure the Banner image group is very simple, just go to the corresponding editing interface on the AnQiCMS backend.

Set Banner image for category page

  1. Log in to the admin backend and navigate:Log in to the AnQiCMS admin interface, then navigate to the left menu bar and select 'Content Management', then choose 'Document Category'.
  2. Select and edit the category: In the document category list, find the category you want to add or modify the Banner image. Click the 'Edit' button on the right of the category to enter the category detail editing page.
  3. Upload Banner Image:In the category editing page, scroll down to find the 'Banner Image' area.You can click the upload button to select an image to upload from your local computer, or you can select from the library of uploaded images.AnQiCMS supports uploading multiple images, which will be displayed as a photo group.In order to maintain the uniformity and aesthetics of the front-end display, it is recommended that you upload images with consistent dimensions.

Set Banner Image for Single Page

  1. Log in to the admin backend and navigate:Similarly, log in to the AnQiCMS backend, navigate to the left menu bar's 'Page Resources', and select 'Page Management'.
  2. Select and edit a single page:In the single-page list, find the single page you want to add or modify the Banner image. Click the 'Edit' button on the right to enter the single page detail editing page.
  3. Upload Banner Image:In the single-page editing page, you will also find a 'Banner image' area.The operation method is the same as the category page, you can upload multiple images to form a Banner image group, and pay attention to maintaining the consistency of image size.

By following these steps, you have completed the task of uploading and configuring the Banner image group for a specific category or single page in the AnQiCMS backend.These image data have already been stored in the system, waiting for the front-end template to call.

Call and display the Banner image group in the template

After completing the backend configuration, we need to modify the front-end template files of the website to display these carefully prepared Banner images to visitors.AnQiCMS powerful template tag system makes this process direct and efficient.

Call the Banner image in the category page template

The template for the category page is usually located/template/{您的模板名称}/{模型table}/list.htmlOr you can specify a custom template file for a specific category in the background (for example/template/{您的模板名称}/article/list-123.html)

You can use these template files in{% categoryDetail %}Tag to get the details of the current category, which includes the Banner image group we uploaded.

{# 假设这是您的分类列表模板(例如:/template/default/article/list.html) #}
{% comment %} 获取当前分类的Banner图片组 {% endcomment %}
{% categoryDetail bannerImages with name="Images" %}

{% if bannerImages %}
    {# 如果存在Banner图片,则进行遍历展示 #}
    <div class="category-banner-slider">
        <ul>
        {% for imageUrl in bannerImages %}
            <li><img src="{{ imageUrl }}" alt="分类Banner图片"></li>
        {% endfor %}
        </ul>
    </div>
{% else %}
    {# 如果没有设置Banner图片,可以显示一个默认图片或不显示 #}
    <div class="default-banner">
        <img src="/public/static/images/default-banner.jpg" alt="默认分类Banner">
    </div>
{% endif %}

In the code above:

  • {% categoryDetail bannerImages with name="Images" %}The label is used to get the current category's Banner image group.bannerImagesIs a custom variable name, you can use any name you like.name="Images"Specified that we need to retrieve the image group data configured on the backend.
  • {% if bannerImages %}Check if the image group exists, which is a good habit to avoid errors on the page when there are no images.
  • {% for imageUrl in bannerImages %}Loop through each image in the image group.imageUrlIn each iteration, it will be the complete URL path of the current image.
  • {{ imageUrl }}The URL of the image is output directly, you can use it in<img>label'ssrcthe attribute.

Call the Banner image in a single page template

The template for a single page is usually located/template/{您的模板名称}/page/detail.htmlOr the custom template file you specify for a specific single page in the background (for example/template/{您的模板名称}/page/about.html)

The way to call the single-page Banner image group is very similar to the category page, but you need to use{% pageDetail %}.

`twig {# Assume this is your single page template (e.g., /template/default/page/detail.html) #} {% comment %} Get the current single page's Banner image group {% endcomment %} {% pageDetail pageBannerImages with name=“Images” %}

{% if pageBannerImages %}

{# 如果存在Banner图片,则

Related articles

How to display recommended attributes (such as headlines, recommendations, sliders) in article lists or detail pages?

In AnQi CMS, in order to make your website content more attractive and able to flexibly display articles of different importance levels or display forms, the system provides a "recommended attribute" feature.By cleverly utilizing these properties, you can easily add "headlinesThis guide will take you in-depth to understand how to set and use these recommended properties in AnQiCMS, making your website content management more convenient.

2025-11-08

How to set up the website to display specific notification information on the front end when it is in "closed site" status?

The website will always encounter times when it needs to be maintained, upgraded, or temporarily adjusted.At this moment, it is crucial for users to see a friendly and clear prompt instead of a cold error page, which is vital for the image and user experience of the website.Fortunately, AnQiCMS provides a very convenient and flexible "shutdown" function, allowing you to easily manage the maintenance status of the website and display customized notification information to front-end visitors.Next, let's take a look at how to set the "shutdown" status of the website in the AnQiCMS backend

2025-11-08

How to batch regenerate all content thumbnails to fit the new frontend display size?

When the visual style of a website needs a complete overhaul, or to adapt to the ever-changing size of device displays, we often need to adjust the size of image thumbnails.AnQiCMS (AnQiCMS) fully understands this and provides a convenient and efficient solution for such needs.How to batch regenerate thumbnails for all content in response to adjustments in front-end display dimensions to ensure the aesthetic beauty and loading efficiency of the website, which is a concern for many operators.Why do you need to regenerate the thumbnail? Thumbnails play a crucial role in website operations

2025-11-08

How to implement automatic conversion of uploaded images to WebP format to optimize front-end loading and display speed?

In today's content operation, website loading speed is crucial for user experience and search engine rankings.Images are an important part of web content, and their loading performance is often a key factor affecting overall speed.AnQiCMS (AnQiCMS) is well aware of this and provides a convenient image optimization feature, especially converting images uploaded to WebP format automatically, which can significantly improve the display speed of the website's front-end.### WebP format: A speed booster for front-end loading WebP is an image format developed by Google

2025-11-08

How to display the view count of articles in the article list or detail page?

In website operation, the number of article views is a very intuitive and important indicator, which not only reflects the popularity of the content but also provides data support for the optimization of subsequent content strategies.For websites built using AnQiCMS, displaying the number of views on article lists or detail pages is a relatively simple operation. With the powerful template tag features provided by AnQiCMS, we can easily achieve this requirement.Understanding the "Page Views" feature of AnQiCMS AnQiCMS is built with powerful traffic statistics functionality

2025-11-08

How to remove empty lines generated by conditional judgment or loop tags in the template to optimize the display cleanliness of the page source code?

In website operation, we all hope that the website is not only powerful in function, rich in content, but also the source code behind it should be neat and orderly.However, when developing with a flexible template system like AnQiCMS, you may sometimes find that the generated HTML source code contains many blank lines, which are mainly caused by conditional judgment or loop tags in the template.Although these blank lines usually do not have a substantial impact on the functionality of the website, they do indeed reduce the readability of the source code, and bring inconvenience to subsequent maintenance and debugging.

2025-11-08

How to render Markdown content into HTML in AnQiCMS?

In a content management system, Markdown is a lightweight markup language that allows content creators to write in plain text and format it with simple symbols, which can then be easily converted into structured HTML.For AnQiCMS users, using Markdown to write content not only improves efficiency but also ensures consistency and maintainability of content formatting.

2025-11-08

What is the specific usage of the `render` filter in Markdown content rendering?

In Anqi CMS, we often encounter the need to convert text into colorful web elements.Especially when content is written in Markdown format, how to ensure that it can be presented correctly and beautifully to the user is a problem that requires a deep understanding.Today, let's talk about how the `render` filter works in the Anqi CMS Markdown content rendering.

2025-11-08