How to dynamically display different group Banner slideshows on the website homepage?

Calendar 👁️ 72

The banner slideshow on the homepage is an important window to attract visitors' attention and convey core information.By setting it cleverly, we can make the homepage banner slideshow display dynamically according to different marketing goals or content themes, which can not only improve user experience but also effectively guide users to browse.AnQiCMS (AnQiCMS) provides flexible features to help users easily meet this requirement.

Understanding the Banner mechanism of AnQi CMS

In AnQi CMS, the management and display of Banners have a clear logic.The system supports grouping for Banners, which means you can create independent sets of Banner images for different purposes and themes.For example, you can create a group for the header carousel on the homepage, another group for the promotional banner in the sidebar, or a temporary group for a specific promotional event.

Manage these Banner groups and images are usually performed in the Anqi CMS backend management interface.Here, you can upload images, set the link address for each Banner, add Alt text to the images (which is crucial for improving the website's SEO performance and accessibility), as well as provide a brief description and title.The key is that you can create multiple different Banner groups in the background and add corresponding images to each group.

Implement steps: Dynamically display different group Banner carousel

We need to combine the backend settings and the frontend template file calls to dynamically display these group banners on the website homepage.

The first step: Set Banner group and image in AnQi CMS background

First, please log in to your Anqicms CMS backend. Although the specific menu path may vary depending on the version or theme, you will usually find features such as 'Banner Management' or 'Slideshow Management' under 'Page Resources' or 'Content Management'.

After entering the Banner management interface, you will see options to create or edit Banner groups. Here:

  1. Create a new Banner group:For example, you can create a group named "Home Highlight" to display the most important promotional images on the website;Create a new group named "New Products Flash" for scrolling the latest products.The name of the group is the unique identifier you call when using the front-end template.
  2. Upload an image for each group:Upload your prepared banner images under their respective groups. Each image needs:
    • Image file:Choose high-quality, appropriately sized images.
    • Link address (Link):Set the target page after clicking the Banner.
    • Alt text (Alt):Add descriptive text to images to enhance SEO and user experience.
    • Title (Title) and Description (Description):Fill in as needed, this information can be displayed on the front end.
    • Note:It is recommended that all Banner images within the same group be of consistent size to ensure the coordination and uniformity of the carousel effect.

Step two: Call the Banner of the specified group in the website homepage template

After completing the background configuration, we need to modify the website's homepage template file. The AnQi CMS template files are usually stored in/templatethe directory, the homepage file may beindex/index.htmlorindex.html.

AnQi CMS provides a special template tag for calling the Banner list——bannerList. Through this tag'stypeThe parameter allows us to specify which group's Banner to call.

Here is an example code snippet showing how to call different groups of Banners in different areas of the homepage:

{# 首页主要轮播区域 - 调用“首页主推”分组的Banner #}
<div class="main-carousel-section">
    <div class="swiper-wrapper"> {# 假设您使用了Swiperjs等轮播库 #}
        {% bannerList mainBanners with type="首页主推" %}
            {% for item in mainBanners %}
            <div class="swiper-slide">
                <a class="carousel-link {% if forloop.Counter == 1 %}active{% endif %}" href="{{item.Link}}" target="_blank">
                    <img src="{{item.Logo}}" alt="{{item.Alt}}" title="{{item.Description}}" />
                    <div class="banner-content">
                        <h3>{{item.Title}}</h3>
                        <p>{{item.Description}}</p>
                    </div>
                </a>
            </div>
            {% endfor %}
        {% endbannerList %}
    </div>
    {# 添加Swiper的导航、分页等元素 #}
    <div class="swiper-pagination"></div>
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
</div>

{# 首页侧边栏推广区域 - 调用“新品速递”分组的Banner #}
<div class="sidebar-promotion">
    <h3>新品速递</h3>
    <div class="product-banner-list">
        {% bannerList newArrivalsBanners with type="新品速递" %}
            {% for item in newArrivalsBanners %}
            <a class="product-promo-item" href="{{item.Link}}" target="_blank">
                <img src="{{item.Logo}}" alt="{{item.Alt}}" title="{{item.Description}}" />
                <h4>{{item.Title}}</h4>
            </a>
            {% endfor %}
        {% endbannerList %}
    </div>
</div>

Code analysis:

  • {% bannerList mainBanners with type="首页主推" %}This line of code tells Anqi CMS to find the Banner group named "Home Main Push" and assign all the Banner data tomainBannersthis variable.
  • {% for item in mainBanners %}This is a loop statement that will iteratemainBannersover each Banner data. In each iteration, the current Banner data will be stored initemthe variable.
  • {{item.Link}}/{{item.Logo}}/{{item.Alt}}/{{item.Title}}/{{item.Description}}These are the ones you can get fromitemThe Banner data retrieved from the variable corresponds to the links, image addresses, Alt text, title, and description set in the background.
  • {% if forloop.Counter == 1 %}active{% endif %}This is a commonly used technique to mark the first element as 'active' in a carousel, so that the front-end CSS/JavaScript can initialize the carousel effect.forloop.CounterRepresents the current loop count, starting from 1.

Step 3: Style and interaction (implemented through CSS/JavaScript)

It is not enough to simply call out images and links; you also need to write the corresponding CSS to beautify the layout and appearance of the Banner, as well as JavaScript code to implement the animation effects, automatic playback, switch buttons, and pagination for interactive functions.This work usually depends on the front-end carousel library (such as Swiper.js, Owl Carousel, etc.) or custom script you choose.

Optimization suggestion

  • Image optimization:When uploading Banner images on the backend, be sure to pay attention to the image size and file size.Large images can significantly affect the website's loading speed. Anqi CMS provides features such as automatic image compression and conversion to WebP format in the 'Content Settings' section, and it is recommended to make full use of them.
  • Responsive design:For screens of different sizes (PC, tablet, mobile), different banner layouts or images may be required.You can set media queries in CSS to adjust the display of the Banner, and even consider uploading different Banner images for different device sizes in the background (if the system supports it, or by creating different Banner groups and calling them in the front end based on the device type).
  • SEO friendly:Ensure that each Banner image is filled with meaningful contentaltThis not only helps search engines understand the image content, but also provides information to users when the image fails to load.

By following these steps, you can easily implement dynamic display of different group banners on the homepage of the Anqi CMS-built website, thereby better serving your website operation goals.


Frequently Asked Questions (FAQ)

1. Can I display multiple Banner carousels on the same page, each showing content from different groups?

Yes, it can be done. Just as shown in the example in the article, you only need to use the template multiple timesbannerListtag,

Related articles

How to implement the switching display of multilingual website content and adapt to users of different languages?

Today, with the deepening of globalization, a website that supports multilingualism has become a basic requirement for enterprises to expand into international markets and serve global users.AnQiCMS deeply insight into this trend, providing users with a highly efficient and flexible multilingual website content management solution, helping your website easily switch between different language content display and better adapt to users around the world.The core concept of AnQiCMS implementing multi-language website content switching is based on multi-site management.

2025-11-08

How to enable Markdown editor rendering content on the front-end page and display mathematical formulas and flowcharts?

Content operation plays a crucial role in the digital age today.The strength of a Content Management System (CMS) largely depends on its ability to flexibly support a variety of content presentation forms.AnQiCMS (AnQiCMS) leverages its efficient and flexible features to provide a vast space for content creators.Today, we will delve into how to elegantly enable Markdown editor to create content on the Anqi CMS front-end page, and further realize the rendering of mathematical formulas and flowcharts, making your website content more expressive.###

2025-11-08

How to display the current page's canonical URL in the template to optimize SEO?

In website operations, Search Engine Optimization (SEO) is one of the core tasks to enhance website visibility.Among them, the setting and correct display of the canonical URL (Canonical URL) is crucial for avoiding content duplication, optimizing crawling efficiency, and concentrating page weight.AnQiCMS (AnQiCMS) is a highly SEO-focused enterprise-level content management system that provides users with convenient tools for managing and deploying standardized links.What is a Canonical URL?

2025-11-08

How to dynamically display SEO title, keywords, and description (TDK) in the page header?

In website operation, the dynamic display of SEO title (Title), keywords (Keywords), and description (Description) at the page header, abbreviated as TDK, is a core element of search engine optimization (SEO).They not only help search engines understand the content of the page, but are also the key to attracting users to click.For users of AnQiCMS, the system provides a powerful and flexible mechanism to implement TDK dynamic management, ensuring that each page can achieve **SEO performance.**

2025-11-08

How to filter and display articles in a list or category list based on recommended attributes (such as "Top Story

In content management and website operation, how to effectively highlight key information, guide users to focus on specific articles, is the key to improving website effectiveness.AnQiCMS (AnQiCMS) provides a flexible recommendation attribute feature that allows you to easily filter and display articles in article lists or category lists based on attributes such as "Headline" and "Recommended", thus better realizing content operation strategies.

2025-11-08

How to display the article list according to different sorting rules (such as latest, views, custom sorting)?

Managing website content in Anqi CMS, flexibly controlling the display order of article lists is crucial for improving user experience and content distribution efficiency.Whether you want to immediately display the latest released content to visitors, highlight the most popular hot articles, or manually adjust the arrangement of articles according to specific operational strategies, Anqi CMS provides a simple and powerful way to meet these needs.One of the core advantages of AnQi CMS is its intuitive and feature-rich template tag system.

2025-11-08

How to implement content pagination display and customize page navigation style in AnQiCMS template?

As the content of the website becomes richer, how to efficiently display a large amount of information while ensuring a user-friendly browsing experience is an indispensable link in website operation.In AnQiCMS, through the powerful template tag system, we can easily achieve content pagination display and flexibly customize the style of page navigation, making the website content both rich and tidy.--- ### Efficient Content Organization: Implementing Pagination of Content Lists In the AnQiCMS template, the core of implementing content pagination is to use the `archiveList` tag to retrieve document lists

2025-11-08

How to implement a search function on the front end of a website and display a list of search results with highlighted keywords?

When building a rich website, providing an efficient and convenient search function is a key aspect of improving user experience.AnQiCMS (AnQiCMS) has fully considered this from the beginning of its design, through its flexible template engine and built-in tags, we can relatively easily implement search functionality on the website front-end, and further optimize it to make the keywords in the search results stand out and highlight prominently.### Core Mechanism: Understanding the Search Principle of AnQiCMS The core of AnQiCMS website frontend search lies in `search/index.html`

2025-11-08