How to implement dynamic display and link jump of the website homepage Banner carousel in AnQiCMS?

Calendar 👁️ 91

In website operation, an attractive homepage banner carousel is a key element for improving user experience, highlighting core content, and guiding user behavior.AnQiCMS as an efficient and flexible content management system provides an intuitive way to manage and display these dynamic contents.Next, we will explore how to easily implement the dynamic display and link jump of the website homepage Banner carousel using AnQiCMS.

Backstage settings: Prepare your Banner image and link

Firstly, we need to enter the images and related information used for the carousel into the AnQiCMS backend management interface.

You can usually find the configuration items such as 'Banner Management' or similar names under function modules like 'Page Resources' or 'Content Management'. Here, you can perform the following operations:

  1. Add or edit Banner item:
    • Upload image (Logo): Select your Banner image file. To ensure the visual effects and loading speed of the carousel, it is recommended to upload images of consistent size and appropriate size.
    • Fill in the link address (Link)Configure a redirect link for each Banner image.This link can be an in-site article, product detail page, or an external promotional page.Ensure the accuracy of the link, as this is the key to achieving the jump.
    • Fill in the Alt attribute (Alt): Add descriptive Alt text to images. This not only helps search engines understand the content of the image, improves SEO, but also provides information to users when the image fails to load.
    • Fill in the description (Description): You can add a brief description for the Banner image, which is convenient for the front-end template to display when needed.
    • Group Name (Type)This is a very practical feature. AnQiCMS supports setting 'group name' for Banner images, for example, you can create different groups such as 'Home Carousel', 'Product Page Slider', and so on.When calling on the homepage, you can specify only to call the pictures under the "Homepage Carousel" group to achieve flexible management.By default, the Banner will be grouped into the "default" category.

After completing the entry of this information, your Banner data is ready and can be used by the front-end template.

Template call: Display the Banner on the homepage

Next, we need to write code in the homepage template file of the website to call and display these Banner data.

AnQiCMS template files are usually stored in/templateUnder the directory, with.htmlAs a file suffix. It uses a syntax similar to the Django template engine, which is simple and easy to understand.

  1. Locate the home page template:Find the home page template file for your website, usually/template/您的模板目录/index/index.htmlOr/template/您的模板目录/index.html.

  2. UsebannerListLabel call data:AnQiCMS provides a special function to get the Banner list:bannerListLabel. You can call it in the template as follows:

    {% bannerList banners with type="default" %}
        {# 在这里编写循环,展示您的Banner图 #}
    {% endbannerList %}
    
    • banners: You can customize the variable name, which will carry the Banner list data obtained from the background.
    • with type="default": If your Banner image is set to a group, you can specify which group's Banner to call here. For example, if you have created a group named "Home Carousel", you can change towith type="首页轮播"If this parameter is omitted, the Banner of the 'default' group will be called.
  3. Traverse the data and build an HTML structure: bannersIt is an array object, you can useforLoop to iterate over each piece of Banner image data and construct the corresponding HTML structure:

    <div class="banner-carousel">
        {% bannerList banners with type="default" %}
            {% for item in banners %}
                <a href="{{ item.Link }}" target="_blank" class="banner-item">
                    <img src="{{ item.Logo }}" alt="{{ item.Alt }}" />
                </a>
            {% endfor %}
        {% endbannerList %}
    </div>
    
    • {{ item.Link }}: Will dynamically output the redirect link you set in the background.
    • target="_blank": It is recommended to open the Banner link in a new window to avoid users leaving the current page.
    • {{ item.Logo }}: It will dynamically output the URL address of the Banner image.
    • {{ item.Alt }}: It will dynamically output the Alt text you set for the image.

Through the above code, AnQiCMS will dynamically render the background-configured Banner image and link to your website homepage.At this time, each image has the function of clicking to jump.

Implement dynamic carousel effect

AnQiCMS is mainly responsible for providing the data content and structure of the Banner, while the actual carousel animation and interactive effects usually rely on front-end JavaScript libraries and CSS styles to implement.There are many common carousel libraries, such as Swiper, Slick Carousel, Owl Carousel, etc.

Here we take the basic idea of implementing dynamic effects as an example:

  1. Introduce front-end resources:In your template file (usuallybase.htmlorindex.htmlof<head>or<body>Before ending, include the CSS and JavaScript files required for the carousel library you choose. Please note that these static resources are usually stored in/public/static/the directory.

Related articles

How to call and display the contact information set in the background of the AnQiCMS website at the bottom, such as phone number, email?

Clearly display contact information at the bottom of the website, which is crucial for improving user experience and building trust.AnQiCMS as an efficient content management system takes this into full consideration, providing an intuitive and flexible way to manage and display this key information, such as phone numbers and email addresses. ### One, AnQiCMS backend contact settings and management In the AnQiCMS backend management interface, you can easily find and configure the website's contact information.

2025-11-09

How to display the link to the previous and next article on the article detail page in AnQiCMS template?

In AnQiCMS, adding "Previous Article" and "Next Article" navigation links to the article detail page is a key factor in enhancing user experience and guiding users to delve deeper into the website content.The powerful template system of AnQiCMS makes this feature very intuitive and efficient, it uses syntax similar to Django template engine, making it easy for developers to master. AnQiCMS template files are usually suffixed with `.html` and stored in the `/template` directory.

2025-11-09

How to integrate MathJax or Mermaid.js in AnQiCMS page to display mathematical formulas and flowcharts?

Integrate MathJax and Mermaid.js on AnQiCMS page: Easily display mathematical formulas and flowcharts AnQiCMS is an efficient and flexible content management system that excels in meeting various content display requirements.With the increasing richness of technical content, many users may encounter the need to elegantly display mathematical formulas and flowcharts on websites.AnQiCMS integrates its built-in Markdown editor and flexible template support, allowing integration with MathJax and Mermaid.js

2025-11-09

How to implement nested display of multi-level category navigation with the `categoryList` tag in AnQiCMS?

When building a website with comprehensive functionality, a clear and easy-to-navigate category system is the key to improving user experience and optimizing content structure.AnQiCMS as an efficient enterprise-level content management system provides flexible template tags to meet diverse content display needs.Among them, the `categoryList` tag is the core tool for achieving nested display of multi-level classification navigation.

2025-11-09

How to truncate article content in AnQiCMS template and display “...”?

How to elegantly truncate article content and display "..." in the AnQiCMS template?In website content operation, we often need to display the summary of articles, products, or single-page content on list pages, aggregation pages, or search results.These summaries not only make the page look neater, but also help visitors quickly understand the content outline, so that they can decide whether to click to read the full text.

2025-11-09

How does AnQiCMS ensure that each site's page content is displayed independently under multi-site management?

AnQiCMS was designed from the beginning to fully consider the needs of enterprises and content operators for multi-site management and is committed to providing a highly efficient and independent solution.When you create multiple sites in AnQiCMS, the system ensures that the page content of each site can be displayed independently, without interference, and also allows for limited cross-site content interaction when needed.

2025-11-09

How to display the category name and link of the article belonging to the AnQiCMS document detail page?

In AnQiCMS, we often hope that visitors can clearly see the category name of this article when browsing the document details, and can conveniently click on the category link to further explore more content under the same category.This not only optimizes the user experience and makes the website structure more intuitive, but also helps search engines better understand the content hierarchy of the website, improving SEO effects. To implement this feature on the document detail page of AnQiCMS, we need to make some simple modifications to the template file.AnQiCMS uses something similar to Django

2025-11-09

How to process thumbnails and display images of different sizes in AnQiCMS templates?

Managing website content in AnQiCMS, image processing is undoubtedly a key factor in improving user experience and page loading speed.A website that can intelligently present thumbnails of images in appropriate sizes for different display scenarios can not only greatly improve the page response speed but also make the visual layout more coordinated and beautiful.The AnQi CMS provides a powerful and flexible image thumbnail processing mechanism, which can be easily implemented, whether through unified settings in the background or on-demand calls in the frontend template.### Back-end Content Settings

2025-11-09