How to display the Banner slideshow image on the homepage or a specific group?

Calendar 👁️ 94

The home page and banner slideshow of specific groups, which is a key element to attract visitors and display core content on the website.A system with convenient management and flexible display, which can make your website operation twice as efficient.AnQiCMS (AnQiCMS) takes advantage of its intuitive design and powerful template tag features, allowing you to easily handle these visual elements, whether it's creating an eye-catching homepage banner or customizing exclusive promotional images for specific category pages, you can do so with ease.

Today, let's delve into how to make your Banner slideshow images come to life in Anqi CMS.


One, background settings: prepare for your banner content

In Anqi CMS, managing Banner images is very flexible. You can set up a universal carousel for the entire site, or add exclusive Banners for specific content (such as category pages or standalone pages).

1. Configure the homepage or custom group Banner carousel

This is the most common Banner application scenario, usually used to display core values or the latest activities on the homepage.

  • Enter the Banner management interface:Log in to the AnQi CMS backend, where you will find a dedicated area for managing banners.In here, you can add, edit, sort and group your Banner images.
  • Add a new Banner image:Click the 'Add' button, you can upload images and fill in the following information for each image:
    • Image file:This is the main body of the Banner. It is recommended to upload images of the same size to ensure the coordination of the carousel effect.
    • Link address:When a visitor clicks on the Banner, which page will it jump to? You can set a related internal page link or an external event link.
    • Alt text:This is an important description of the image, which not only helps search engines understand the content of the image, but also improves SEO effects, and can provide alternative information when the image cannot be loaded.
    • Introduction:A brief description that can be displayed as a Banner title or subtitle on the front end.
    • Group name:This is the key to managing the Banner carousel images. Anqi CMS allows you to set different 'group names' for Banner images (for example, you can create a group named 'Home Slide' and another named 'Promotion Event').By default, all Banners that have not been assigned to a specific group will be grouped under "default".Reasonably utilizing grouping can help you call different Banner collections on different pages.

2. Configure a dedicated Banner for a specific category or independent page

Sometimes, you may want a unique Banner for a product category page or an independent 'About Us' page to enhance its thematic nature.The Anqi CMS also provides such a convenient feature.

  • Category page Banner:
    • Go to the "Content Management" -> "Document Category" interface in the background.
    • Select the category you want to edit, click the "Edit" button to enter the category detail page.
    • Find the "Banner image" setting item on the page. You can upload one or more images here as the exclusive banner carousel for this category page.These images will only be effective on this category page and will not interfere with the Banner on other pages.
  • Independent Page Banner:
    • Go to the background's 'Page Resources' -> 'Page Management' interface.
    • Select the independent page you want to edit, click the "Edit" button to enter the page details page.
    • Find the "Banner Image" setting item on the page. You can upload exclusive banner carousel images here, which will be displayed only on this independent page.

Template call: Display your Banner on the website front end

After the background configuration is completed, the next step is to use the tags provided by Anqi CMS in the corresponding template files on the website frontend to call and display these banner images.AnQi CMS uses a syntax similar to the Django template engine, making template writing intuitive and efficient.

1. Call the Banner carousel on the homepage

Generally, the home page banner is placed at the top of the page, for example, in your template fileindex.htmlor the public header filepartial/header.html.

To call the homepage carousel configured in the "Banner Management" backend, you can usebannerList.

{% bannerList banners %}
    <div class="swiper-container"> {# 假设您使用Swiper或其他前端轮播库 #}
        <div class="swiper-wrapper">
            {% for item in banners %}
            <div class="swiper-slide {% if forloop.Counter == 1 %}active{% endif %}">
                <a href="{{item.Link}}" target="_blank">
                    <img src="{{item.Logo}}" alt="{{item.Alt}}" />
                    {# 如果您在后台Banner的“介绍”字段填写了文字,也可以在这里显示 #}
                    {% if item.Description %}
                    <div class="banner-description">
                        <h5>{{item.Description}}</h5>
                    </div>
                    {% endif %}
                </a>
            </div>
            {% endfor %}
        </div>
        {# 如果需要,可以添加分页器和导航按钮 #}
        <div class="swiper-pagination"></div>
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>
    </div>
{% endbannerList %}

Code analysis:

  • {% bannerList banners %}This is the core tag, it will retrieve all banner image data belonging to the "default" group from the background and assign it tobannersThis variable (you can customize the variable name, for examplehomepageBanners)
  • {% for item in banners %}: Traverse through the loopbannersvariable, you can access the information of each Banner image one by one.
  • item.LinkGet the jump link after clicking the Banner.
  • item.LogoGet the URL address of the Banner image.
  • item.AltGet the Alt text of the Banner image.
  • item.Description:Get the introduction text of the Banner image.
  • {% if forloop.Counter == 1 %}active{% endif %}:This is a small trick,forloop.CounterIt will return the current loop count (starting from 1). You can use it to add a picture to the first Banner.activeClass name, commonly used to initialize display in many front-end carousel components (such as Swiper, Owl Carousel, etc.)
  • {% endbannerList %}and{% endfor %}: withbannerListandforThe tag is used for pairing, indicating the end of a code block.

Call the Banner of the specified group:

If you have set different groups for Banner in the background (such as "Activity Slide"), when calling in the template, just givebannerListlabel totypeJust set the parameters:

`twig {% bannerList activityBanners with type=“Activity Slides” %}

{# 同样地,在这里

Related articles

How to implement language switching functionality for multilingual sites in Anqi CMS?

When our website is aimed at serving global customers, providing multilingual support has become an indispensable feature.This can not only help us expand the international market, but also significantly improve the access experience of users in different languages.AnQiCMS (AnQiCMS) fully understands this need, therefore, it has made multilingual support one of its core highlights, allowing us to easily build multilingual websites and switch languages.How to implement language switching for multi-language sites in AnQi CMS

2025-11-08

How to create pagination navigation for document lists, Tag lists, and other Anqi CMS features?

In website operation, providing clear and easy-to-use pagination navigation for content lists not only greatly improves user experience but also optimizes search engine crawling efficiency, helping content to be discovered better.AnQiCMS (AnQiCMS) knows this and therefore provides powerful and flexible pagination tags in template design, allowing content operators to easily create pagination navigation for document lists, tag lists, and so on. We will discuss together how to implement this feature in AnQi CMS templates, organizing your website content neatly.--- ###

2025-11-08

How to generate and display the breadcrumb navigation of the current page in Anqi CMS

When we browse websites, we often see a line at the top or bottom of the page indicating the current location path, such as “Home > Product Category > Electronic Products > Laptop”.This is what we commonly call 'breadcrumb navigation', which not only clearly informs us of our location but also makes it convenient for us to quickly return to the previous level page, greatly enhancing the website's user experience and navigation efficiency.In Anqi CMS, implementing and displaying breadcrumb navigation is a very easy thing to do.The system is built-in with special template tags that can intelligently adapt to the content structure of the current page

2025-11-08

How to set and display the TDK (Title, Description, Keywords) on the homepage of Anqi CMS?

In website operation, TDK (Title, Description, Keywords) play a crucial role, they are the first window for search engines to understand the content of the website, directly affecting the visibility and click-through rate of the website in search results.An optimally optimized TDK can not only improve the website's SEO performance but also accurately convey the core value of the website to potential visitors.AnQiCMS is a content management system that focuses on SEO optimization, providing users with a convenient and efficient way to set up and manage the TDK of the homepage.

2025-11-08

How to customize or override the JSON-LD structured data in AnQi CMS?

The AnQi CMS has always been committed to providing efficient and flexible solutions in content operation and search engine optimization.Structured data, especially JSON-LD, is an important means to improve the visibility of website content in search engines.It can help search engines understand the page content more accurately, thereby giving it the opportunity to display richer search results (i.e., rich media summaries) and attract more users to click. AnQi CMS understands the importance of structured data, and has preset some default JSON-LD structured data for you in the system design.

2025-11-08

How to obtain the background custom global parameters in the template?

In AnQi CMS, the flexibility and maintainability of the website are one of its core advantages.Content operators and developers often need to dynamically adjust some global information of the website without modifying the template code, such as the company name, contact number, and even some marketing campaign links.These are the background custom global parameters that are the key to achieving this requirement.Today, let's delve into how to easily obtain and display these custom global parameters configured in the Anqi CMS template.### Why do we need global parameters? Imagine that

2025-11-08

How to display the current year or a specified format of time in the template?

In website operation, it is often necessary to keep the web page content up-to-date or accurately display the time of specific events, whether it is the copyright year in the footer, the publication date of the article, or the update time of the product. These dynamic time information can make the website look more professional and active.AnQiCMS provides a very flexible and intuitive way, allowing you to easily display the current year or specify the format of time in templates. Next, we will explore two main methods together, allowing your AnQiCMS website to flexibly display various time information.## One

2025-11-08

How to customize URL rewrite rules in AnQi CMS to optimize SEO?

In website operation, the website structure is not just a string of characters for accessing pages, but also a key factor in the website's performance in search engines.A clear, meaningful, and search engine-friendly URL (Uniform Resource Locator) that can significantly improve the SEO effect of the website, helping the content to be discovered and understood more easily.AnQiCMS (AnQiCMS) knows this and therefore integrated powerful pseudo-static and URL customization features into the system design from the beginning, allowing website operators to flexibly configure URL rules to meet different SEO strategy needs.

2025-11-08