How to use `for` loop to iterate over multiple home page Banner items obtained from `bannerList`?

Calendar 👁️ 59

In modern web design, the home page banner is undoubtedly an important window for attracting users' attention and conveying core information.A dynamic and beautiful Banner area can greatly enhance the visual appeal and user experience of a website.As an experienced website operation expert, I deeply understand the strong and flexible content management of AnQiCMS (AnQi CMS).Today, let's delve into a very practical skill in the AnQiCMS template: how to cleverly useforLoop tag, cooperate withbannerListLabel, accurately obtain and display multiple home page Banner items of yours.

Understand the Banner mechanism of AnQiCMS withbannerListTag

In AnQiCMS, the management of the home page Banner is usually done in the background, where you can upload images, set links, add description text, and even group Banners according to different scenarios.How do you present these data saved on the front-end template? At this point,bannerListthe label comes into play.

bannerListThe tag is a dedicated tag provided by AnQiCMS, which is responsible for fetching all or specific group Banner data from your website backend. When you use it in the template,{% bannerList banners %}This syntax, AnQiCMS will organize the obtained Banner information into a convenient handlingarray or list objectAssign it to the variable you specify (for example, here)bannersEach element in this array represents an independent Banner item.

Core operation: useforLoop through the Banner item

SincebannerListThe tag provides us with a collection of Banner data, so next, we can make use of the powerful template engine of AnQiCMS,forLoop tags, visit and display these Banner items one by one.

forThe basic structure of the loop is:{% for item in collection %}...{% endfor %}. Here,collectionthat isbannerListThe returned Banner collection (i.e., as mentioned above in thebannersvariable), anditemIt represents the single Banner data being processed in each loop.

Let's look at a basic example to show how to iterate and output the key information of each Banner item:

{% bannerList banners %}
    {% for item in banners %}
        <a href="{{ item.Link }}" target="_blank">
            <img src="{{ item.Logo }}" alt="{{ item.Alt }}" />
            <h5>{{ item.Description }}</h5>
        </a>
    {% endfor %}
{% endbannerList %}

In this code block:

  • {% bannerList banners %}Firstly, we callbannerListLabel, assign all the Banner data obtained to a variable namedbanners.
  • {% for item in banners %}: Then, we start to traversebannersthis collection.

Related articles

What are the required or commonly used parameters of the `bannerList` tag to configure the home page banner?

As an experienced website operations expert, I fully understand the importance of the homepage banner for the first impression of website visitors and the guidance of user behavior.In AnQiCMS, the `bannerList` tag is the core tool we use to manage and present these key visual elements.It features a concise and powerful design that allows content operators to easily achieve diverse homepage banner display needs.

2025-11-06

How to display the Banner image list through the `bannerList` tag on the Anqi CMS homepage?

As an experienced website operations expert, I am well aware of the importance of the homepage banner for website visual appeal, user guidance, and brand promotion.In AnQiCMS such an efficient and flexible content management system, making good use of its built-in tags can help us easily achieve various content display needs.Today, let's delve into how to skillfully use the `bannerList` tag on the homepage of AnQiCMS to display your exquisite Banner image list.--- ### AnQiCMS and Banner

2025-11-06

What parameters does the `{% tagDataList %}` tag support to refine

Hello!As an experienced website operations expert, I am more than happy to provide a detailed explanation of the various parameters supported by the `{% tagDataList %}` tag in AnQiCMS, as well as how to skillfully utilize them to build more accurate and attractive content displays.In AnQiCMS, content tags (Tag) are an important way to organize and associate content, helping users quickly find topics of interest.

2025-11-06

How to display the list of all associated documents under the Tag tag detail page?

As an experienced website operations expert, I am well aware of the core role of tags (Tag) in content management and website optimization.A well-designed tagging system not only enhances user experience and helps visitors quickly find the content they are interested in, but is also an indispensable part of search engine optimization (SEO).AnQiCMS provides very flexible and powerful support for the Tag tag function, making it easy for us to achieve this goal.

2025-11-06

How to set the image link (`Link`) for each Banner in `bannerList`?

As an experienced website operations expert, I am well aware of the importance of every detail for website user experience and operation effectiveness.The banner (Banner) serves as the 'face' of the website, not only carrying the responsibility of beauty, but also as a key point for guiding users and conveying core information.In an efficient and flexible system like AnQiCMS, setting precise image links (`Link`) for each Banner is the basis for achieving this goal.

2025-11-06

How to correctly reference the image address of the home page Banner (`item.Logo`) in the template?

As an experienced website operations expert, I am well aware of the importance of the website homepage banner.It is not only the "face" of the website, carrying the brand image and core promotional information, but also the first visual point for users to enter the website.For users of AnQiCMS, how to efficiently and accurately refer to these banner images in templates, especially the image address `item.Logo` contained within them, is a common and basic requirement in daily operations. Today

2025-11-06

What is the role of the `item.Alt` field in the `bannerList` tag for SEO, and how to set it?

As an experienced website operation expert, I am more than happy to delve into the importance of the `bannerList` tag's `item.Alt` field in the AnQi CMS for website SEO and how to set it up effectively.In modern website operations, images are not only visual elements, but they also carry important information transmission functions, especially in search engine optimization (SEO).

2025-11-06

How to use the `type` parameter to call the homepage Banner under a specific group in the Anqi CMS backend?

As an expert who deeply understands the art of website operation, I am well aware of the importance of the homepage banner for the image and marketing promotion of the website.It is not only a visual focus, but also a key area for conveying core information and guiding user behavior.AnQiCMS (AnQiCMS) offers high flexibility in Banner management, especially through its `bannerList` tag combined with the `type` parameter, allowing us to accurately call the home page Banner under specific groups according to different operational needs.Today, let's delve into this practical feature. ###

2025-11-06