How to configure and display the Banner slideshow image on the Anqi CMS homepage?

Calendar 👁️ 73

In Anqi CMS, configuring and displaying the banner carousel image on the homepage is a key step to enhance the visual appeal and content presentation effect of the website.This process involves the upload and grouping management of background images, as well as the writing of front-end template code.

1. Configure the Banner carousel image in the background

The Banner image on the homepage is not randomly stacked; it requires careful management to ensure it displays as expected on the front end. Anqi CMS provides a flexible way to handle these images:

  1. Image upload and grouping: Usually, you will find an entry specifically for managing Banners in the "Page Resources" or "Content Management" related area of the backend.Here, you can upload your Banner image.When uploading each image, the system will allow you to enter some key information, such as:

    • Link Address: The target page to jump to when the user clicks on the Banner.
    • Image description (Alt): Used for image SEO optimization and auxiliary functions, this text will be displayed when the image cannot be shown.
    • Group name (Type)This is an extremely important setting. By setting the same 'group name' (such as 'home slide' or 'home carousel') for a group of Banner images, you can accurately call this group of images in the front-end template to achieve the need to display different Banners at different locations.The system will have a 'default' group by default.

    When uploading images, it is recommended that you use images with consistent dimensions and proportions, which can prevent the carousel from jumping or layout confusion when switching, thereby providing a smoother user experience.

  2. Category and dedicated banner for single page (for reference, not directly used for the home page carousel):It is worth mentioning that Anqi CMS also allows you to upload exclusive Banner images for specific category pages or single pages (such as the "About Us" page) through the "Document Classification" or "Page Management" feature.Although these images are usually used on their respective pages rather than on the homepage carousel, understanding these features can help you customize the visual elements for different parts of the website when needed.

Second, display the Banner carousel in the front-end template

Once your Banner image is configured in the background and grouped, the next step is to display them on the homepage through template tags.AnQi CMS uses the Django template engine syntax, calling data through specific tags.

To display the home page banner carousel, you need to usebannerListthe tag. This tag will retrieve the corresponding banner image list based on the specified group name.

This is a typicalbannerListLabel usage example:

{# 使用 bannerList 标签获取名为“首页幻灯”的 Banner 列表 #}
{% bannerList banners with type="首页幻灯" %}
    {# 检查是否有 Banner 图片,避免页面空白 #}
    {% if banners %}
    <div class="banner-carousel">
        {% for item in banners %}
        {# 为第一个 Banner 添加 active 类,通常用于轮播图的初始显示状态 #}
        <a href="{{item.Link}}" target="_blank" class="banner-item {% if forloop.Counter == 1 %}active{% endif %}">
            <img src="{{item.Logo}}" alt="{{item.Alt}}" class="banner-image" />
            {# 如果 Banner 有描述或标题,也可以在这里显示 #}
            {% if item.Description %}
            <div class="banner-caption">
                <h5>{{item.Title}}</h5> {# 虽然文档中没有明确提到Title字段,但常用于Banner描述 #}
                <p>{{item.Description}}</p>
            </div>
            {% endif %}
        </a>
        {% endfor %}
    </div>
    {% else %}
    {# 当没有 Banner 图片时,可以显示一个占位符或提示信息 #}
    <div class="no-banner-placeholder">
        <p>暂无轮播图片,敬请期待!</p>
    </div>
    {% endif %}
{% endbannerList %}

Code analysis:

  • {% bannerList banners with type="首页幻灯" %}This line of code tells the system that we want to retrieve all banners with the group name "Home Slide" and store them in a namedbannersIn the variable. If you have not set a group, or want to call the Banner of the default group, you can omit itwith type="..."Section.
  • {% if banners %}This is a conditional judgment to ensure that the carousel structure is only rendered when the Banner image list is obtained.
  • {% for item in banners %}: This is a loop structure that will iterate overbannersEach Banner image in the list. In each loop, the details of the current image will be stored initemthe variable.
  • item.Link: Get the link address of the Banner image.
  • item.LogoGet the actual file path of the Banner image. This is the most commonly used field, usually the large image of the Banner.
  • item.AltGet the image description text of the Banner image.
  • item.Description:Get the introduction text of the Banner image.
  • {% if forloop.Counter == 1 %}active{% endif %}This is a commonly used technique to dynamically add the first element of the carouselactiveCSS class. Many front-end carousel libraries (such as Swiper, Owl Carousel, etc.) depend on this class to initialize the carousel.

3. Further improve the display effect.

It is not enough to form a dynamic slideshow just by displaying images through template tags.In order to achieve smooth switching, automatic playback, navigation buttons, and other functions, you also need to combine the frontend CSS styles and JavaScript code.

  1. CSS style:Define responsive styles for carousel containers and images to ensure they display well on different devices. For example, set the image width to 100%, height auto, or useobject-fitThe attribute to control the display style of the image within the container.
  2. JavaScript carousel library:Introduce popular JavaScript carousel libraries (such as Swiper.js, Owl Carousel, etc.), and then initialize your Banner carousel container according to their documentation.These libraries usually provide rich features and animation effects, making your home page banner more interactive.

By following these steps, you can flexibly configure and display the Banner carousel images on the homepage of Anqi CMS, adding dynamics and attractiveness to your website.


Frequently Asked Questions (FAQ)

  1. Why is my home page Banner image not displaying?First, please check if you have already

Related articles

How to set independent display templates for different article categories in AnQi CMS?

Our Aanqi CMS offers high flexibility in content display, one very practical feature is that it can set independent display templates for different article categories.This means you can customize unique visual styles and layouts for different categories of content, thereby highlighting the content, improving user experience, and even meeting specific SEO requirements. To achieve this goal, we need to start from several aspects such as preparing the template file, setting up the background, and designing the template content.Understanding the concept of categories and article templates in AnQi CMS

2025-11-08

How to implement the 'Recommended Attributes' tag highlighting in the front-end of AnQi CMS?

AnQi CMS provides a powerful content management function, among which the "recommended attribute" tag is a very practical tool in content operation.It can help us effectively organize and highlight the important content on the website, whether it is to improve the user experience or to better optimize SEO, these properties can play a key role.Understanding "Recommended Attributes": A Tool for Content Operations In Anqi CMS, "Recommended Attributes" are special identifiers set for each document (such as articles, products, etc.).

2025-11-08

How to display the contact information and social media links on AnQi CMS templates?

In website operation, clearly and effectively displaying contact information and social media links is crucial for building customer trust and promoting interaction.AnQiCMS (AnQiCMS) provides a convenient and flexible way to easily integrate key information into website templates. --- ### One: Prepare: Configure contact information and social media in the Anqi CMS backend Before displaying contact information and social media on the website front end, we need to configure it in the Anqi CMS backend.This is like preparing a complete business card for our website.1

2025-11-08

Does AnQi CMS support automatic conversion of images to WebP format to optimize display speed?

During the process of building and operating a website, the speed of image loading is always one of the key factors affecting user experience and search engine optimization.The size of an image directly affects the loading efficiency of a page.Many website operators are looking for more efficient image formats to improve website performance.So, for the Anqi CMS we are using, does it support automatic conversion of images to WebP format to optimize the display speed of the website?The answer is affirmative. Anqi CMS fully considers the needs of website performance optimization, and built-in support for WebP image format.This practical feature

2025-11-08

How to obtain and display custom parameter fields on the Anqi CMS article detail page?

In website operation, we often need to display personalized information beyond standard titles, content, and publication dates.AnQi CMS, with its highly flexible content model, gives us the ability to add custom parameter fields to articles, products, and other content, thereby meeting various diverse display needs.This article will thoroughly explain how to obtain and elegantly present these custom parameter fields on the article detail page of Anqi CMS, making your content more expressive.

2025-11-08

How to display the directory or title structure of article content in AnQi CMS?

On a content-rich website, providing a clear table of contents or title structure for long articles can greatly enhance the user's reading experience and also help search engines better understand the hierarchy of page content, thereby having a positive impact on SEO performance.AnQi CMS is well-versed in this and provides flexible and powerful features to easily meet this requirement.

2025-11-08

How to use the Tag feature of AnQi CMS to display related content aggregation pages on the front end?

The AnQi CMS provides a powerful and flexible tag (Tag) feature that helps us better organize content, improve the website's SEO performance, and provide users with a more convenient way to discover content.By making good use of tags, we can easily create content aggregation pages, allowing visitors to quickly find related articles or products based on their interests.Understanding the Core Value of Tag FunctionWhen we assign one or more tags to a document

2025-11-08

How can AnQi CMS ensure that the HTML content in the rich text editor is secure and displayed correctly?

In website content management, the use of rich text editors greatly facilitates the creation and beautification of content.However, ensuring that the HTML content entered by the user is both safe and correctly displayed on the front end while allowing free formatting is a core challenge that every content management system must face.AnQiCMS as an enterprise-level content management system provides multi-layered security mechanisms in this regard.Firstly, AnQiCMS has established a solid security foundation from the bottom of the system architecture.

2025-11-08