The `bannerList` tag provides additional filters to handle the images or text of the Banner?

Calendar 👁️ 58

As an experienced website operations expert, I am happy to deeply analyze AnQi CMS for youbannerListThe function of the tag, and answer questions about its filter. When building a visually appealing and content-efficient website, a Banner (banner ad or carousel) is undoubtedly a key element in attracting users' attention.Security CMS provides convenient for thisbannerListTag, but its function is far more than a simple content call.


Flexible use of Anqi CMS'sbannerListTag: fine control of content and format

In the template design of AnQi CMS,bannerListTags are an important tool for efficiently retrieving the website's frontend Banner list.At first glance, you might wonder whether this tag itself provides additional "filters" to directly handle the Banner's images or text, such as automatically cropping images, truncating text, etc.The answer is,bannerListThe core responsibility of the tag is inFiltering and obtaining data contentHowever, this does not mean that you cannot fine-tune the image or text processing of the Banner content.In fact, AnQi CMS is strong and flexibleGeneral filter mechanism, Endowing you withbannerListultimate control over the data obtained.

bannerListTag: Core of data acquisition

First, let us make it clearbannerListThe positioning of the label. It is intended to accurately retrieve the required Banner data set from the background database according to your configuration. Its main parameters include:

  • siteIdIf you are managing multiple sites in Anqicms,siteIdthe parameter allows you to specify which site to retrieve Banner data from, realizing flexible calls of multi-site content.
  • typeThis isbannerListThe most commonly used parameter, with a default value of"default". You can create multiple Banner groups in the background (such as “Home Page Big Picture”, “Sidebar Promotion” etc.), and then throughtype="分组名"Call the Banner of a specific group. This greatly improves the modularity and maintainability of Banner management.

When you usebannerListWhen a tag is encountered, it returns an array of Banner objects. In the template'sforloop, you can access the specific properties of each Banner object, such asitem.Logo(Image address),item.Link(link address),item.Description(description text) anditem.Alt(Image Alt Attribute Text). For example, a basic call example is as follows:

{% bannerList banners with type="homepage-main" %}
    {% for item in banners %}
        <a href="{{item.Link}}" target="_blank">
            <img src="{{item.Logo}}" alt="{{item.Alt}}" />
            <h5>{{item.Title}}</h5> {# 假设存在Title字段 #}
            <p>{{item.Description}}</p>
        </a>
    {% endfor %}
{% endbannerList %}

As you can see,bannerListThe tag itself does not contain any parameters directly used for image scaling, text cropping, and other operations.The design philosophy separates the data acquisition from the formatted display processing, thus providing greater flexibility.

Flexible General Filter: A Tool for Content Formatting

AlthoughbannerListTags do not come with formatting filters, but the Anqi CMS template engine provides richuniversal filters. These filters can be applied to any variable, includingbannerListEach one obtained in the label loopitemThe property. This means that you can format the image address, text description, Alt attribute, etc. of the Banner in various detailed ways.

Applying a filter to image content:

For banner images, we often need to optimize them to ensure their display effect and loading speed on different devices. At this time,thumbandurlencodeFilters are particularly useful:

  • thumbFilter:It can generate thumbnails of specified size based on the original image address, which is crucial for implementing responsive images and speeding up page loading.
    
    <img src="{{ item.Logo|thumb }}" alt="{{ item.Alt }}" />
    
  • urlencodeFilter:If the Banner linkitem.Linkmay contain special characters, useurlencodeto ensure correct link parsing and avoid jump errors.
    
    <a href="{{ item.Link|urlencode }}" target="_blank">
    

Filter applied to text content:

The display of text on the banner (such as titles, descriptions, Alt attributes) also needs to be adjusted according to design requirements, such as uniform length, removal of HTML tags, or case conversion. Anqi CMS providestruncatechars/safe/striptags/replaceand a series of case conversion and other filters:

  • truncatecharsortruncatewordsFilter:Used to truncate long descriptions and add ellipsis to maintain the layout. You can choose to truncate by character count (truncatecharsOr truncate by word count ( truncatewords).
    
    <p>{{ item.Description|truncatechars:50 }}</p> {# 描述文字截取前50个字符 #}
    
  • safeFilter:If Banner descriptionitem.DescriptionThe content is entered from the rich text editor, which may contain HTML tags. UsesafeThe filter can indicate to the template engine to render these HTML tags as content instead of escaping them.
    
    <p>{{ item.Description|safe }}</p> {# 渲染包含HTML的描述文字 #}
    
  • striptagsFilter:On the contrary, if you want to remove all HTML tags from the description text and keep only plain text content, you can usestriptags.
    
    <p>{{ item.Description|striptags|truncatechars:100 }}</p> {# 移除HTML标签后截取文字 #}
    
  • upper/lower/capfirstFilter:Used to convert text to uppercase, lowercase, or title case to meet specific design requirements.
    
    <h5>{{ item.Alt|upper }}</h5> {# 将Alt文字转换为大写 #}
    
  • replaceFilter:Used to replace specific strings in text, such as unified SEO keywords or revised copywriting.
    
    <img src="{{item.Logo}}" alt="{{ item.Alt|replace:"旧关键词,新关键词" }}" />
    

Integrate these filters into

Related articles

How can I use the `type` parameter to display multiple different styled Banner areas on the homepage?

As an expert in website operation who is well-versed in AnQi CMS, I fully understand your need to display a diversified Banner area on the homepage.A vibrant and rich homepage is often the key to attracting users and enhancing brand image.AnQi CMS is born to meet such needs with its powerful flexibility and customizability.Today, let's delve into how to巧妙运用 `type` parameter skillfully in Anqi CMS to achieve diversified display of the home page Banner.### Display of various banners on the AnQi CMS homepage

2025-11-06

How to ensure the compatibility of the home page Banner across different browsers?

In the world of website operation, the homepage banner acts as the "facade" of the website, and its display effect directly affects the first impression and conversion rate of users.However, due to the variety of browsers used by users and the rapid iteration of versions, how to ensure that this crucial Banner maintains a consistent and excellent visual experience on all browsers has become a challenge for many website operators.As an experienced website operator who has been deeply involved with AnQiCMS for many years, I am well aware of AnQiCMS' strong ability to solve such problems

2025-11-06

Does the `bannerList` tag support the scheduling publishing or deactivation of Banners?

As an expert in website operations for many years, I deeply understand that in the ever-changing market environment, the timeliness and accuracy of website content are crucial for attracting users and improving conversion.Especially, as the 'front door' of the website, the release and deactivation of Banner often need to be closely coordinated with marketing activities, holiday promotions, and other events.Today, let's delve into the `bannerList` tag of AnQiCMS (AnQiCMS) to see if it supports the scheduling of Banner publishing or deactivation, as well as how we can deal with it in actual operation.###

2025-11-06

How to batch modify the link or text content of the home page Banner?

As an experienced website operation expert, I am well aware of the importance of the homepage banner in terms of website visual impact, brand image, and user guidance.In daily operations, we often encounter the need to batch adjust the link or text content of the homepage Banner, whether it is to cooperate with market activities, update product information, or optimize SEO strategies, it is crucial to complete these operations efficiently and conveniently. AnQiCMS (AnQiCMS) is an enterprise-level content management system that takes into account the actual needs of operators from the outset.Today, let's delve into it

2025-11-06

How to integrate third-party ad code in the home page Banner?

As an experienced website operations expert, I know that how to efficiently use website space for monetization and promotion is a focus for many enterprises and content operators in an increasingly competitive online environment.AnQiCMS is an efficient and flexible content management system, its powerful customizability provides a solid foundation for us to achieve these operational goals.Today, let's delve into a common operation requirement: how to integrate third-party advertising code into the AnQiCMS homepage banner.

2025-11-06

Does the `bannerList` tag support random display of an item from the Banner list?

In modern website operation, Banner (banner advertisement) serves as a visual focus, which is crucial for attracting users' attention and conveying core information.Flexibly manage and display Banner, especially when it is necessary to bring users a sense of novelty, random display has become a highly关注的 demand.

2025-11-06

How to add a mouse hover effect to the homepage Banner?

As an experienced website operation expert, I fully understand your pursuit of website visual effects and user experience.The home page banner acts as the "face" of the website, and its design and interaction directly affect the first impression of visitors.Today, let's delve into how to add an attractive mouse hover effect to your homepage banner in AnQiCMS, making your website more vibrant.### Ingenious Use of CSS

2025-11-06

The `bannerList` tag affects the page loading speed when fetching Banner data?

As an experienced website operations expert, I fully understand your concern about website loading speed.In today's internet environment where user experience is paramount, even milliseconds of delay can affect user retention and conversion.AnQiCMS (AnQiCMS) is a modern content management system developed based on the Go language, which has always put high performance and high concurrency as the core goal from the very beginning.Therefore, when you ask whether the "bannerList" tag affects the page loading speed when fetching Banner data?When this question is asked

2025-11-06