How to display the list of dynamic Banner images configured in the website?

Calendar 👁️ 73

The website's banner area is like a dynamic promotional window, its visual appeal and content delivery efficiency directly affect the first impression of visitors to the website.A well-designed Banner that can quickly capture the user's attention, effectively showcasing the brand image, latest activities, or core products.In AnQiCMS (AnQi CMS), by taking advantage of its powerful content management features, you can easily configure and display a dynamic Banner image list, keeping your website fresh and attractive.

Understand the Banner configuration logic in AnQiCMS

In AnQiCMS, configuring the dynamic banner image list is an intuitive and flexible process.These scrollable images can usually be directly linked to specific content units of a website, such as a category page or an independent single page.

When you edit a document category or a single page in the background, you will find a dedicated area for setting the "Banner image" region.Here, you can upload multiple images, and the system will treat them as a banner group for the specific category or page.To ensure the coordination and uniformity of the front-end display effect, we usually recommend that you upload images of the same size.

In addition to this page-level Banner setting, AnQiCMS also provides a more advanced Banner management method.Through the corresponding function module on the backend, you can create and manage multiple independent Banner groups.This means that you can design and configure a set of exclusive Banner images for the homepage of the website, different special event pages, and even seasonal promotional activities.Each group can have its own unique set of images and be identified by a custom name.This fine-tuned configuration capability brings great flexibility and convenience to website content operation.

Use cleverlybannerListLabel: Core of Dynamic Banner Display

To display the meticulously configured dynamic banner image list on the front end of the website, AnQiCMS provides a core template tag——bannerList. This tag is the key to implementing dynamic Banner display, which can obtain and provide the corresponding Banner image data according to your configuration, and can be flexibly traversed and rendered in the template.

bannerListThe basic form of a tag is:{% bannerList 变量名称 %}. You can specify a variable name that is easy to identify in the template, such asbanners. Then, through standard loop structures, such as{% for item in banners %}You can access and process each Banner image in the list one by one.

This tag also supports some practical parameters to allow you to fine-tune the Banner data you obtain:

  • siteId:If your AnQiCMS has deployed the multi-site management feature and you want to call the Banner data of other sites, you can use this parameter to specify the ID of the target site.But this parameter is usually not needed in most single-site application scenarios.
  • type:This isbannerListOne of the most commonly used parameters of the tag. By default, if not specifiedtypeA parameter that will retrieve the Banner image under the "default" group. But if you have created multiple Banner groups in the background (such as "Home Slide", "Product Display Banner", etc.), you can settype="分组名称"Call the Banner image list of a specific group accurately.This allows you to display different banner collections as needed in different areas of the website, greatly enriching the page's expressiveness.

Inside the loop,itemThe variable represents each banner image in the list, which includes the following keywords that can be called in the template:

  • Id:Each Banner image has a unique identifier ID in the system.
  • Logo:The complete URL address of the Banner image on the server, which is the core field for displaying the image.
  • Link:When the visitor clicks on the Banner image, it will jump to the target URL address.
  • Description:The description information of the Banner image, which can usually be used as an image title or brief description.
  • Alt:Image alternative text (Alt Text), which is very important for SEO optimization and improving website accessibility (for example, when images cannot be loaded or for visually impaired users).

Guide to displaying dynamic Banner image lists in templates

UnderstoodbannerListAfter the powerful function of the tag, we will demonstrate how to apply it to your website template.Suppose you want to display a carousel Banner on the website homepage, and these images have already been configured in a group named "Homepage Slides" in the background.

You can use it in the website'sindex.htmlOr write similar code snippets in other template files that need to display Banners:

<div class="main-banner-container"> {# 假设这是一个用于Banner轮播的外部容器 #}
    {% bannerList homeBanners with type="首页幻灯" %} {# 获取“首页幻灯”分组的Banner列表 #}
        {% for bannerItem in homeBanners %}
        <a href="{{bannerItem.Link}}" target="_blank" class="banner-slide {% if forloop.Counter == 1 %}active-slide{% endif %}">
            {# 结合thumb过滤器生成缩略图,并用于懒加载,提高性能 #}
            <img src="{{bannerItem.Logo|thumb}}" alt="{{bannerItem.Alt}}" loading="lazy" class="responsive-banner-image"/>
            {% if bannerItem.Description %}
                <div class="banner-text-overlay">
                    <h3>{{bannerItem.Description}}</h3>
                </div>
            {% endif %}
        </a>
        {% endfor %}
    {% endbannerList %}
</div>

Let's

Related articles

How to add hreflang tags in templates to support multi-language SEO?

With the increasing trend of globalization, many websites are facing the challenge of providing content to users of different languages or regions.To ensure that your multilingual website performs well in search engines and accurately guides users to their preferred language version, adding the `hreflang` tag is crucial.AnQiCMS (AnQiCMS) is an enterprise-level content management system that deeply supports multilingualism and provides a convenient way to implement this feature in templates.### Understand the role of the hreflang tag `hreflang`

2025-11-09

How to display multi-language switch options for the current site?

How to easily add multilingual switching options to a website in AnQi CMS?With the continuous deepening of globalization trends, many enterprises and content operators find that having a website that supports multilingual is crucial for expanding the market and serving users in different regions.AnQi CMS understands this need, therefore it has built-in powerful multilingual support functions, allowing you to easily manage and display content in different languages. After your website content is prepared in multiple languages, the next step naturally is to provide visitors with an intuitive language switcher.This can not only improve the user experience

2025-11-09

How to design a basic template and allow other pages to inherit it?

Building websites in AnQi CMS, efficient and flexible template design is the key to improving development efficiency and maintaining website consistency.Among them, designing a basic template and allowing other pages to inherit it is the core strategy to achieve this goal.AnQi CMS adopts a syntax similar to the Django template engine, making template inheritance intuitive and powerful. ### Lay the Foundation: Create Your Basic Template First, let's create the basic template skeleton of a website. In Anqi CMS, all template files are stored in the `/template` directory

2025-11-09

How to create reusable template code snippets (macros)?

In the daily content operation of Anqi CMS, we often encounter some interface elements or code structures that need to be used repeatedly.For example, a standardized article list item, a product display card with a unified style, or a footer contact information with specific layout information.If writing this code manually every time, it is not only inefficient but also prone to inconsistent formatting issues.This is where the "Macro" feature provided by Anqi CMS becomes particularly important, as it helps us easily create reusable template code snippets, greatly enhancing the efficiency and quality of template development.###

2025-11-09

How to display or customize the error pages (such as 404, 500) and shutdown notifications of a website?

In the operation of the website, visitors may encounter pages that cannot be found for various reasons or temporary issues with the server, and may even be unable to access the website during maintenance and upgrades.In these situations, a well-designed error page (such as 404, 500) and a friendly shutdown prompt can not only greatly improve user experience but also maintain the professional image of the website to a certain extent and search engine optimization (SEO).AnQi CMS is an efficient content management system that provides a flexible way to display and customize these important pages.###

2025-11-09

How to use AnQiCMS to customize the display layout of the article detail page?

AnQiCMS provides a very flexible and powerful content management system, allowing us to easily customize the display layout of article detail pages.In order to enhance user experience, optimize SEO, or better showcase the brand characteristics, AnQiCMS can help us achieve these goals through its intuitive template system and rich tag features.How can we proceed specifically? We can delve into these aspects step by step.### 1. Understanding AnQiCMS template mechanism First

2025-11-09

Does AnQiCMS support displaying different detail page styles based on different content models?

In website operation, we often encounter such needs: different types of content, even on the same website, also need to have completely different display styles.For example, a product detail page of an e-commerce website needs to highlight product images, prices, inventory information, etc., while the blog article detail page may focus more on the reading experience, author information, and publication date.This ability to customize the style of detail pages based on content type (also known as content model) is crucial for improving user experience and content professionalism.Then, while using AnQiCMS

2025-11-09

How to display only articles of specific categories in the article list?

When managing website content in Anqi CMS, we often need to flexibly control the display of article lists, for example, only displaying articles under specific categories on a certain page.This not only helps to organize the content of the website accurately, but also greatly improves the browsing experience of visitors, helping them find the information they are interested in faster.AnQi CMS provides powerful template tag features, making this requirement simple and intuitive.The core of achieving this goal lies in the `archiveList` template tag of Anqi CMS.This tag is used to obtain the 'universal key' for the article list from the database

2025-11-09