How to call and display the Banner image of the AnQiCMS category page

Calendar 👁️ 66

In website operation, the category page is not only the classification display of content, but also the key entry for users to explore the website and gain a deeper understanding of products or services.A well-designed category banner that can effectively enhance the visual appeal of the page, strengthen the brand image, and guide users to the next step.AnQiCMS as an efficient content management system provides a flexible way to manage and call these banner images.

Next, we will discuss in detail how to set up a Banner image for the category page in AnQiCMS and display it on the website frontend.

One, backend management: configure Banner image for category

First, you need to upload and configure the Banner image for your category page in the AnQiCMS backend management interface.

  1. Enter category managementLog in to the AnQiCMS backend, navigate to the 'Content Management' module, select 'Document Category' or 'Product Category', find the specific category where you want to add a Banner image, click 'Edit' to enter its detailed settings page.
  2. Upload Banner ImageIn the category editing page, you will see a feature option named "Banner image".Here you can upload one or more images.Generally, it is recommended to upload banner images of consistent dimensions to maintain the neatness and professionalism of the page.These images can be static images, or used as slide show materials.
  3. Save SettingsAfter uploading, be sure to click the "OK" or "Save" button at the bottom of the page to ensure that your configuration takes effect.

After completing this step, your categorized data will include Banner image information, and the next step is to call them in the front-end template.

Second, template call: Display Banner image on the category page

We need to edit the corresponding template file to display these banner images on the category page of the website (usually the article list page or product list page).The AnQiCMS category page template is usually namedlist.htmlor more specificlist-{分类ID}.htmlfor examplearticle/list.htmlorproduct/list-10.html)

AnQiCMS provides a namedcategoryDetailThe powerful template tag, specifically used to retrieve the details of the current category or a specified category, which includes the Banner image we just uploaded to the backend.

1. Get the Banner image data of the category

In the template of the category page, you can obtain the list of Banner images of the current category in the following way:

{% categoryDetail categoryImages with name="Images" %}

here,categoryImagesIs a variable name you define, used to store the obtained Banner image array.name="Images"It tells the system that you need to get the category Banner image group. Because you are already on the current category page, socategoryDetailThe label will automatically identify and retrieve data from the current category without additional specificationidortokenParameter.

ObtainedcategoryImagesis an array of image URLs, you can iterate through the array as needed, or simply take the first image.

2. Display multiple Banner images (carousel)

If you have uploaded multiple Banner images and want to display them as a carousel on the front end, you can combine AnQiCMS'sforloop tags to iterate:

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

In this example,itemthe variable will get a picture URL from the array in each loop.altthe attribute usescategoryDetail with name="Title"the tag dynamically retrieves the current category title to enhance SEO friendliness..category-banner-carouseland.carousel-itemare some custom CSS classes, you may also need to use JavaScript libraries (such as Swiper, Owl Carousel, etc.) to implement the carousel effect.

3. Display a single Banner image (as the page top background)

If your design only needs to display a Banner image at the top of the category page, for example, as the background image of the page, then you can only get the first image in the array:

{% categoryDetail bannerImages with name="Images" %}
{% if bannerImages %}
    {% set firstBanner = bannerImages[0] %} {# 获取第一张图片URL #}
    <div class="page-top-banner" style="background-image: url('{{ firstBanner }}');">
        <h1>{% categoryDetail with name="Title" %}</h1>
        <p>{% categoryDetail with name="Description" %}</p>
    </div>
{% else %}
    {# 如果没有Banner图,可以显示一个默认的背景或者占位内容 #}
    <div class="page-top-banner default-bg">
        <h1>{% categoryDetail with name="Title" %}</h1>
        <p>欢迎访问我们的{% categoryDetail with name="Title" %}分类</p>
    </div>
{% endif %}
{% endcategoryDetail %}

Here, we use{% set firstBanner = bannerImages[0] %}Assign the URL of the first image obtained tofirstBannerVariables, then use them as CSS background images. This method is flexible and common, and can integrate well with page design. Similarly,altThe logic of properties and default placeholders should also be considered.

Summary

By using the simple category management feature of AnQiCMS backend, combined with flexible and powerful template tags, you can easily add and display banner images on the website's category page.Whether it is a multi-image carousel or a single-image background, AnQiCMS can provide a convenient implementation method to help you create a visually attractive and excellent user experience website.


Frequently Asked Questions (FAQ)

1. Why did I upload the category Banner image on the backend, but it doesn't display on the front page?This is usually because your current category page template (for examplelist.htmlorlist-{分类ID}.htmlThe corresponding template call code was not added. Please check your template file to ensure it has been used.{% categoryDetail categoryImages with name="Images" %}This tag is used to retrieve and display images. If the template does not contain this code, or the code is incorrect, the Banner image will not be displayed.

2. What will be displayed on the page if no Banner image is set under the category?This depends on how you handle the case of no Banner image in the template. In the above example code, we used{% if categoryImages %}to determine if there is image data. IfcategoryImagesEmpty, you can choose to display a default placeholder image, a preset background color, or simply not display the Banner area to maintain the integrity and design consistency of the page content.

3. Can I set different Banner display modes for different categories? For example, one category uses a carousel, and another category only uses a single image?Of course, you can.The template mechanism of AnQiCMS is very flexible. A method is to specify different template files for different categories.article/list-carousel.htmlorarticle/list-single-banner.htmlThen write the carousel or single image call code in these templates. Another method is to dynamically determine the display logic within the same category template by judging certain characteristics of the current category (such as category ID, custom fields, etc).ifConditional statements are used for judgment and rendering.

Related articles

How to obtain and display the detailed description information of AnQiCMS categories?

In website operation, clear and detailed classification descriptions are crucial for user experience and search engine optimization.AnQiCMS as a powerful content management system provides a flexible way to manage and display these category information.This article will delve into how to retrieve and effectively display detailed category descriptions on the frontend page in AnQiCMS.

2025-11-08

How to implement nested display of multi-level categories in AnQiCMS navigation menu?

In website construction, a clear and easy-to-use navigation menu is crucial for improving user experience and the overall structure of the website.AnQiCMS provides flexible settings for managing the navigation menu, allowing users to easily implement nested hierarchical classification display, thereby better organizing website content and guiding visitors to explore.To implement multi-level nested navigation, we mainly complete it through the "Navigation Settings" function in the AnQi CMS backend.This feature is located in the "Background Settings" area, it can not only manage the top navigation of the website, but also create various custom navigations as needed

2025-11-08

How to display the subcategory list under the AnQiCMS category page?

In AnQiCMS, you can easily display the subcategory list under the category page with flexible template tags.This is crucial for building a clear website structure, improving user navigation experience, and optimizing search engine crawling efficiency.AnQiCMS powerful template system and its Django-style tag syntax make the display of such dynamic content intuitive and efficient.To implement displaying the subcategory list under the category page, the following steps are mainly involved:

2025-11-08

How does AnQiCMS display the list of all top-level categories?

In website construction and content operation, clear classification navigation is the foundation of user experience, as well as the core of content organization.For users using AnQiCMS, how to efficiently display the list of all top-level categories of the website is the first step in building the website structure.AnQiCMS with its flexible template engine and rich built-in tags makes this task exceptionally simple and intuitive.

2025-11-08

How to create a custom template for AnQiCMS website to achieve personalized display?

AnQiCMS with its flexible and efficient features provides a wide space for personalized display of website content.If you want your website to have a unique look and function, creating a custom template is undoubtedly the way.By deeply customizing the template, you can fully control every detail of the website, from brand image to user experience, achieving high levels of personalization and standing out among many websites.This article will guide you to understand how to create and apply custom templates in AnQiCMS, helping you to turn your design ideas into reality and realize the personalized display of the website

2025-11-08

What template types does AnQiCMS support, and how do you choose the most suitable display mode for the website (adaptive, code adaptation, PC + mobile end)?

AnQiCMS as an efficient and customizable content management system provides a variety of flexible modes for displaying website content to meet the diverse needs of different users.Understanding these template types and their applicable scenarios is crucial for building a website with a good user experience, easy management, and search engine optimization.AnQiCMS provides three main template types for users to meet the display needs of different websites.They are adaptive templates, code adaptation templates, and independent PC + mobile site templates.Each pattern has its unique characteristics and applicable scenarios

2025-11-08

How to correctly call and display the title and content of the article in the template?

When using AnQiCMS to build and manage websites, the title and content of articles are core elements. Their correct invocation and display are directly related to the visual presentation, user experience, and search engine optimization of the website.Understanding how to efficiently and accurately handle this information in the AnQiCMS template is the key to website content operation and template customization.AnQiCMS's template system adopts syntax similar to the Django template engine, which provides great flexibility and customizability for content display.In the template, you will find that variables are usually enclosed in double curly braces

2025-11-08

How to utilize the flexible content model of AnQiCMS to customize unique display fields for different types of content (such as articles, products)?

AnQiCMS, this is a content management system driven by the Go language, which performs very well in content management, especially its flexible content model function.As website operators, we often need to publish various types of content, such as detailed product introductions, professional technical articles, vivid case studies, and so on.Each content has its unique display requirements and information structure.Traditional content management systems may require cumbersome secondary development to meet these differences, but AnQiCMS's flexible content model is exactly born to solve this pain point, allowing us to easily customize

2025-11-08