How is the `bannerList` tag used to fetch and display the carousel of the website homepage or a specific group?

Calendar 👁️ 74

When building modern websites, the banner carousel is a common element used to enhance visual appeal and convey important information.They are usually located in prominent positions on the website, such as at the top of the homepage, to display the latest activities, featured products, or important announcements.In AnQiCMS (AnQiCMS), managing and displaying these carousels becomes very convenient, mainly due to its powerful template tag system, especiallybannerList.

bannerListThe tag is a template tag specially designed by Anqi CMS for website carousel ads, which can help us easily obtain preset carousel ad data from the background and display it flexibly on the website front-end.Through this tag, you can easily load and display carousel images at any location on the website (such as the homepage, product category page, or event special page).

bannerListHow do tags work?

bannerListThe tag works by retrieving the carousel data you have pre-configured from the Anqi CMS backend.These carousel data are usually set uniformly in the corresponding management module on the backend, for example, in document classification or single page management, you can upload and set multiple Banner images for specific categories or pages.

In the template file, you can usebannerListLabel to retrieve this data. Its basic usage is to combineforLoop, traverse, and output information for each carousel image. The tag will assign the obtained carousel data to a variable you specify (such asbanners),then you can access the specific properties of each image in this variable.

Core features and parameter analysis

bannerListThe tag provides several practical parameters to meet the needs of different scenarios:

  • type(Group Name):This isbannerListOne of the most commonly used parameters of the tag. By default,typehas a value of"default". But you can set different groups for the carousel in the background, for example, set a group named "Home Big Picture" for the homepage, and set a group named "Product Promotion" for a product category page.Specify in the tagtype="分组名"You can accurately call the carousel of a specific group, thus realizing different carousel content displayed in different areas or pages of the website. For example, if you create a group named "Slide" in the background, you can use it in the template bytype="幻灯"Call it.

  • siteId(Site ID):If your Anqi CMS system has enabled the multi-site management feature and you want to call data from other sites, you can do so bysiteIdParameters are used to specify the target site. For most single-site operation users, it is usually unnecessary to fill in this parameter, as the system will automatically obtain the data of the current site.

WhenbannerListThe label gets the carousel data and then assigns it to the variable you define in the form of an array object (for examplebanners) atforIn the loop, each element of the array (usually nameditemEach represents a carousel, and it includes several key fields:

  • Id:The unique identifier of each carousel, usually used for internal logic processing, and is rarely displayed directly on the front-end page.
  • Logo:Carousel image URL (URL), this is the most core field when displaying images on the front end.
  • Link:Target link address where the carousel clicks.
  • Description:A brief description of the carousel, which can be displayed below the image or in the prompt box.
  • Alt:Image alt text. This is crucial for SEO and improving website accessibility.Even if the image cannot be loaded, users can understand the content of the image through text.

Actual operation: how to call in the templatebannerList

To display the carousel on your website template, you need tobannerListembed the tag into the corresponding.htmlThe template file contains. The following is a typical call example that shows how to retrieve the carousel of the default group and display it as clickable images:

{# 假设这是网站首页的模板文件,调用默认分组的轮播图 #}
<div class="banner-carousel">
    {% bannerList banners %}
        {% for item in banners %}
        <a href="{{item.Link}}" target="_blank">
            <img src="{{item.Logo}}" alt="{{item.Alt}}" />
            {# 如果有描述,也可以在这里显示 #}
            {% if item.Description %}
                <p>{{item.Description}}</p>
            {% endif %}
        </a>
        {% endfor %}
    {% endbannerList %}
</div>

If you need to call a specific group carousel, for example, a group named "Slideshow" is set in the background, the code will be slightly modified:

{# 调用名为“幻灯”的分组轮播图 #}
<div class="slider-area">
    {% bannerList banners with type="幻灯" %}
        {% for item in banners %}
        <a href="{{item.Link}}" target="_blank">
            <img src="{{item.Logo}}" alt="{{item.Alt}}" />
        </a>
        {% endfor %}
    {% endbannerList %}
</div>

In the actual carousel component, we often need to add a specialactiveclass name to make it default display. The Anqi CMS template engine providesforloop.CounterSuch a loop counter can help us easily achieve this:

{# 为第一张轮播图添加 active 类名 #}
<div class="swiper-wrapper">
    {% bannerList banners %}
        {% 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}}" />
            </a>
        </div>
        {% endfor %}
    {% endbannerList %}
</div>

In this way,bannerListLabel combinationforThe loop makes the dynamic loading and display of carousel content intuitive and easy to maintain. You only need to update the carousel content in the background, and the front page will automatically synchronize to display the latest data.

Expand applications and **practice

bannerListThe flexibility of tags is not limited to the homepage. You can apply them to:

  • Category page:Set a dedicated top carousel for different product category pages, displaying the latest products or events in that category.
  • Single Page:For example, a single-page like “About Us” or “Contact Us”, or also utilizebannerListImage representing the label display.
  • Special event page:Customized carousel images to attract users for specific marketing activities or special content.

When configuring the carousel, there are several practices worth noting:

  1. Image size consistency:Try to upload images with consistent size and proportions. This ensures that the carousel transitions are visually smooth and aesthetically pleasing, and avoids layout jumps caused by images of different sizes, affecting user experience.
  2. Optimize image size:Use a compression tool to optimize the image file size of the carousel to speed up page loading, improve user experience, and increase search engine ranking.
  3. ImproveAltProperties:For each carousel image:AltFill in meaningful descriptions. This not only helps visually impaired users understand the content of the image but also improves the visibility of the image in search engines, which is greatly beneficial for the SEO performance of the website.

BybannerListThe tag, Anqi CMS provides powerful and convenient tools for website operators, allowing

Related articles

How to build a clear breadcrumb navigation through `breadcrumb` tags to enhance users' sense of positioning on the website?

In website operation, how to keep visitors from getting lost in the vast content while browsing, and maintain a clear sense of orientation, is a crucial issue.Imagine if a user delves into a page on a website and is unclear about where they came from or their level, they are likely to feel confused and even choose to leave.At this time, a well-designed and functional breadcrumb navigation can play a key role, it is like a 'road sign' in the digital world, providing users with a clear return path.AnQiCMS (AnQiCMS) is deeply skilled in content management and user experience

2025-11-08

How to implement the `navList` tag for flexible display of top, bottom, or sidebar navigation menus on a website?

The website navigation is a guide for users to explore the website content and is also an important clue for search engines to understand the website structure.A well-designed, flexible navigation system that can greatly enhance user experience and website SEO performance.In AnQiCMS, the `navList` tag is just such a core tool that gives us great freedom, allowing us to easily build and manage navigation menus at various positions such as the top, bottom, and sidebars of the website.

2025-11-08

How to use the `tagDetail` and `tagDataList` tags to display information about a specific tab page and its associated documents?

AnQiCMS (AnQiCMS) is a flexible and efficient content management tool trusted by many operators.It is crucial to effectively present content classification and organization methods when building a functional and user-friendly website.Especially for the need to associate different content through "tags", mastering the use of the `tagDetail` and `tagDataList` template tags can make your website's tag page not only beautiful but also informative, greatly enhancing user experience and search engine optimization (SEO) effects.

2025-11-08

What are the applications of the `pageDetail` and `pageList` tags in displaying single-page content and list presentation?

When using AnQiCMS to build a website, the display of single-page content and page lists is an indispensable part.Whether it is an independent content page like "About Us" or a series of links in the website footer navigation, they all need flexible and efficient ways to manage and present.In AnQiCMS, the `pageDetail` and `pageList` tags are powerful tools designed to meet these needs.They each focus on different application scenarios and yet complement each other

2025-11-08

What global website information and contact details can the `system` tag and `contact` tag retrieve and display?

In the daily operation of AnQiCMS, the global information and contact information of the website are highly concerned by users and frequently change.How to efficiently and uniformly manage and display this information is an important standard for measuring the flexibility of a content management system.AnQiCMS provides an extremely convenient solution for calling website content and contact information through its unique template tag system, especially the core tags `system` and `contact`.

2025-11-08

How to dynamically generate and display SEO titles, keywords, and descriptions for `tdk` tags on different pages?

In website operation, the title (Title), keywords (Keywords), and description (Description), known as TDK, are indispensable core elements of search engine optimization (SEO).They not only directly affect the display of the website on the search engine results page (SERP), but also determine whether users click to enter your website.

2025-11-08

How to use the `archiveParams` tag to retrieve and display the content of the custom parameter fields of the document?

In daily website operations, we often encounter the need that standardized content fields can no longer meet the diversified display of information.For example, a product detail page may need to display unique attributes such as "model", "material", "warranty period", etc., while a regular article may need additional notes such as "source of the article", "estimated reading time", etc.

2025-11-08

How to customize the display template for articles, products, and single pages in AnQiCMS?

In AnQiCMS, customizing the display templates for articles, products, and single pages is a very flexible and powerful feature that allows you to create exclusive display styles for different types of content according to the unique needs of your website.By carefully designed templates, not only can the user experience be improved, but also the focus of the content can be better highlighted, achieving the unity of brand style.AnQiCMS uses a template engine syntax similar to Django, which means if you are familiar with this concise and intuitive syntax, you can quickly get started.

2025-11-08