How to display a custom Banner group in a single page in AnQi CMS?

Calendar 👁️ 80

In website operation, we often need to display a set of exquisite pictures on specific single pages, such as the carousel of product special page, the promotional Banner of event introduction page, or the group photos showing the company's style on the "About Us" page.AnQiCMS (AnQiCMS) fully considers these needs, providing an intuitive and efficient way for you to easily implement the display of custom Banner group images on a single page without writing complex code.

Configure single page Banner group image in AnQi CMS backend

The AnqiCMS integrates the Banner group image function directly into the single-page editing interface, making it very convenient to manage.

First, you need to log in to the Anqi CMS backend management system.Find and click on 'Page Resources' under the left navigation bar.Here, you can choose to edit an existing single page or create a brand new one.

After entering the single-page editing interface, scroll down and you will see a region named "Banner image".This area is exactly where you upload and manage the exclusive Banner group image for this single page.You can click the upload button to select multiple images you wish to display.The Anqi CMS supports batch uploads, and to achieve **display effects, it is recommended that you upload images of the same size, which will be more coordinated and beautiful in the frontend display.After uploading, these images will be bound to the current single page.

Display the Banner group in the template

After completing the background image upload and configuration, the next step is to figure out how to display these Banner group images on the website front-end page.AnQi CMS uses a syntax similar to the Django template engine, allowing data calls through concise template tags.

The core template tag for the Banner group on a single page ispageDetail. This tag helps us get the detailed information of the current single page, which includes the group image data we uploaded. These group images will be namedImagesThe field stores.

To display these group images in a single-page template (usually named)page/detail.htmlor a custom single-page template such aspage/about.html), you can write the template code like this:

{# 使用 pageDetail 标签获取当前单页面的 Images 字段,并将其赋值给变量 pageImages #}
{% pageDetail pageImages with name="Images" %}

{# 检查是否存在 Banner 组图 #}
{% if pageImages %}
<div class="banner-carousel">
    <ul>
    {# 循环遍历 pageImages 数组,展示每一张 Banner 图 #}
    {% for item in pageImages %}
        <li>
            {# 图片的 src 属性直接使用 item 变量,因为它就是图片的 URL #}
            {# alt 属性可以获取当前单页面的标题,提升 SEO 和可访问性 #}
            <img src="{{item}}" alt="{% pageDetail with name="Title" %}" />
        </li>
    {% endfor %}
    </ul>
</div>
{% else %}
{# 如果没有上传 Banner 图,可以显示一个默认内容或留空 #}
<div class="no-banner-placeholder">
    此页面暂无 Banner 组图。
</div>
{% endif %}

In this code block:

  • {% pageDetail pageImages with name="Images" %}: We go throughpageDetailTag to specify the retrieval ofImagesField content and store it inpageImagesthe variable.
  • {% if pageImages %}This is a conditional judgment to ensure that the subsequent picture display logic is executed only when the single page has indeed uploaded the Banner group image, to avoid page errors.
  • {% for item in pageImages %}We useforLoop throughpageImagesarray. In each iteration,itemThe variable will represent the URL of the current image.
  • <img src="{{item}}" alt="{% pageDetail with name="Title" %}" />Here it is used directlyitemAs an imagesrcThe attribute value. For SEO-friendliness and user experience, the image'saltThe property we called the title of the current single page.

If you only need to get the first Banner image as the main visual of the page, or use it as a CSS background image, you can further optimize:

{% pageDetail pageImages with name="Images" %}
{% set firstBanner = "" %}
{% if pageImages and pageImages|length > 0 %}
    {# 获取数组中的第一张图片URL #}
    {% set firstBanner = pageImages[0] %}
{% endif %}

{% if firstBanner %}
    {# 作为普通图片显示 #}
    <img src="{{firstBanner}}" alt="{% pageDetail with name="Title" %}" class="single-page-banner" />

    {# 或者作为背景图应用到某个 div 上 #}
    <div class="hero-section" style="background-image: url('{{firstBanner}}');">
        <h1>{% pageDetail with name="Title" %}</h1>
        <p>{% pageDetail with name="Description" %}</p>
    </div>
{% endif %}

By following these steps, you can flexibly display the custom Banner group image on the single page of Anq CMS.This greatly simplifies the process of content editing and template development, allowing you to focus more on the presentation of content and the optimization of user experience.


Frequently Asked Questions (FAQ)

  1. Ask: If I want to display different Banner groups on different single pages, do I need to create a separate template for each page? Answer:It is not necessary. The "Banner Image" feature of Anqi CMS is independently configured for each single page.You just need to upload the exclusive Banner group image on each single page editing interface.In the template, usepageDetail with name="Images"When called, the system will automatically retrieve the Banner group image bound to the current single page being accessed, without the need for you to write a different template file for each page.

  2. Ask: Can other content types (such as article categories, product categories) also set Banner groups? Answer:Yes, AnQi CMS's content model design is very flexible.The article category and product category both support setting Banner group images.In the category editing interface, you will also find similar 'Banner image' options, the upload method is the same as the single page.In the template, you can usecategoryDetail with name="Images"Tag to call the Banner group image of the category.

  3. Q: What problems can be caused by inconsistent Banner image sizes uploaded? How to avoid them? Answer:If the size of the uploaded Banner image is inconsistent, it may cause layout confusion, image distortion, or poor carousel effect on the front end, affecting the beauty of the page.To avoid this situation, it is recommended to ensure that the same set of Banner images have the same width and height when designing or uploading images.You can configure the processing method and size of the image thumbnail in the "Content Settings" backend, but it is best to unify the image size at the source file stage.

Related articles

How to format timestamps in the AnQi CMS template to display them in a friendly date/time format?

In the display of website content, how to present the timestamp data stored in the background in a user-friendly and easy-to-read date or time format is a key factor in improving user experience.Anqi CMS deeply understands this, and provides a simple and efficient tag for template developers —— `stampToDate`, making this process effortless. ### Understanding Timestamps in AnQi CMS In many content models of AnQi CMS, such as articles, products, or categories, time data is typically stored in the form of a 10-digit timestamp.

2025-11-08

How does the Anqi CMS scheduled publishing function control the display time of article content?

In content operation, the timing of content release is often closely related to the propagation effect.To help website administrators plan and distribute content more flexibly and efficiently, AnQiCMS (AnQiCMS) provides a very practical feature - scheduled publishing.This feature allows you to precisely control the display time of article content on the website, realizing the automation and intelligence of content publishing.

2025-11-08

How to prevent content scraping in Anqi CMS and add watermark display to images?

In the era where content is king, the value of original content is self-evident, however, the problems of content plagiarism and image theft are becoming increasingly rampant.For website operators, how to effectively protect their hard work, prevent malicious collection of content, and add exclusive identification to images is a key link in maintaining brand image and content rights.AnQiCMS (AnQiCMS) is well aware of this pain point and has built-in features to address these challenges.

2025-11-08

How can AnQi CMS automatically extract the first image in the article content to display as a thumbnail?

In website content operation, carefully selecting and setting thumbnails for each article is a routine and time-consuming task.These small images can effectively attract visitors' attention and are also the key to maintaining visual consistency on the list page and recommended positions.Anqi CMS deeply understands this, providing users with a very convenient feature: automatically extracting the first image from the article content to display as a thumbnail. ### Core Feature Unveiling: Automatic Thumbnail Extraction Mechanism Anqi CMS showcases its user-friendly side in content management.When you write or edit an article, if you have not manually uploaded a specific thumbnail

2025-11-08

How to truncate, convert case or concatenate strings in AnQi CMS templates?

In the daily use of the Anqi CMS template, flexibly handling text content is the key to improving the display and user experience of the website.Whether it is the concise title of an article, the formatting of user comments, or the combination of product descriptions, mastering the skills of string truncation, case conversion, and concatenation can make your content more expressive.The Anqi CMS is based on the Django template engine syntax, providing a series of powerful and easy-to-use filters (Filters) that make these operations simple and intuitive.

2025-11-08

How to implement a custom prompt display for a website in off-site status in AnQi CMS?

In website operations, for reasons such as maintenance, upgrade, or emergency handling, it is sometimes necessary to temporarily set the website to be offline.A good content management system (CMS) not only provides this basic function, but should also allow you to display custom prompts to visitors during the site shutdown to maintain a good user experience and convey necessary notifications.AnqiCMS (AnqiCMS) provides such a flexible and practical mechanism.Why do you need to shut down and display a custom prompt?The website shutdown does not mean a simple interruption of service, but is an important operational strategy

2025-11-08

How to retrieve and display detailed information of different user groups (such as VIP levels) in Anqi CMS template?

In Anqi CMS, implementing personalized information display based on the user's group membership, such as their VIP level, is a key step to improving website user experience and content monetization capabilities.AnQi CMS provides a powerful and flexible user group management function, and we can easily implement this requirement in the front-end template through simple template tag combinations. ### Understanding Anqi CMS User Groups and VIP System One of the core strengths of Anqi CMS is its user group management and VIP system.

2025-11-08

How does AnQi CMS manage and display website image resources, including categories and details?

In website operation, image resources play a crucial role, not only directly affecting user experience, but also being a key factor in the attractiveness of website content and search engine optimization (SEO).A high-efficient CMS system should provide a complete set of image management and display mechanisms.AnQiCMS (AnQiCMS) considers this aspect quite thoroughly, it provides a series of features to help users easily manage and optimize the image resources of their websites, whether it is from classification and archiving, intelligent processing to multi-scene display, it strives to be simple and efficient.

2025-11-08