How to obtain the Logo image and Banner group image of a specified article or category in Anqi CMS, and apply them flexibly in templates?

Calendar 👁️ 67

Master visual content: Flexible invocation and display of article and category logo images and Banner group images in Anqi CMS

At the time of building and operating a website, eye-catching visual content is the key to attracting users and conveying the brand image.AnQi CMS knows this point and therefore provides powerful and flexible image management and call functions in system design, whether it is for the cover Logo of articles, the representative thumbnail of categories, or the Banner group pictures used to create atmosphere, they can all be easily realized and applied to website templates.

This article will delve into how to obtain the logo image and banner group image of specified articles or categories in Anqi CMS, and present these visual elements ingeniously on your website template.

Understand the image resource management of AnQi CMS

In AnQi CMS, image resources are divided into several categories, and their settings and calling methods in the background are slightly different:

  • Logo image (cover image/thumbnail)This usually refers to a single representative image, such as the cover image of an article, the icon of a category, or a thumbnail.They are usually uploaded directly on the edit page of articles, categories, or single pages or selected from the media library.The Anqi CMS will automatically handle thumbnails, even extracting them from the article content.
  • Banner group imageThis type of image is usually a collection of pictures used for carousel or display of multiple visual contents, commonly found at the top of category pages or in single-page introduction areas.They are also set through multi-image upload in the category or single-page editing pages.
  • Home page banner group imageThis is the global Banner setting for the entire website homepage or specific area, usually configured through the "Navigation Settings" or independent "Banner Management" function in the background, allowing administrators to create different Banner groups.

These images once uploaded and configured on the backend, we can flexibly call and display them in the front-end template using the template tags provided by AnQi CMS.

Second, retrieve and display the logo image and group image of the specified article

For specific articles on the website, we may need to display a unique cover logo image or a selection of group images to enrich the content. Anqi CMS providesarchiveDetailLabel to retrieve this information.

1. Get the article's Logo image (cover image)

The article's Logo image is inarchiveDetailthe corresponding field in the tag isLogo. If you want to get the logo image of the article you are currently browsing, you can use the following method:

<img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />

If you need to get the logo image of an article with a specific ID, for example, an article with ID 10, you can do it like this:

{% archiveDetail articleLogo with name="Logo" id="10" %}
<img src="{{ articleLogo }}" alt="指定文章标题" />

Here, we will assign the URL of the obtained logo image toarticleLogovariable, then use it as<img>label'ssrcproperty. At the same time, for SEO friendliness, it is recommended to use the article title asaltthe value of the attribute.

2. Get the group photo (multiple photos) of the article

The group photo of the article, inarchiveDetailthe corresponding field in the tag isImages. It is different from the Logo image,Imagesfield returns an array of image URLs, so we need to usefora loop to iterate and display them.

{% archiveDetail articleImages with name="Images" %}
{% if articleImages %} {# 确保组图存在才渲染 #}
<div class="article-gallery">
    {% for imgUrl in articleImages %}
    <img src="{{ imgUrl }}" alt="文章图片描述" />
    {% endfor %}
</div>
{% endif %}

In the above code, we first obtained the article list through{% archiveDetail articleImages with name="Images" %}get the article's group image list and assign it toarticleImagesTo avoid empty content when there is no group image, we use{% if articleImages %}to make a judgment. Then,{% for imgUrl in articleImages %}Loop through each image URL in the array and useimgUrlas<img>label'ssrc.

The third, get and display the Logo image and Banner group image of the specified category

For the category page of a website, it is usually also necessary to have representative visual elements, such as category Logo images and Banner groups used at the top of the page. At this time, we can usecategoryDetail.

1. Obtain the category's Logo image (thumbnail)

The category's Logo image is incategoryDetailthe corresponding field in the tag is alsoLogo. If you want to obtain the current category's Logo image:

<img src="{% categoryDetail with name="Logo" %}" alt="{% categoryDetail with name="Title" %}" />

If you need to retrieve the logo image of a specified category ID, for example, the category with ID 5:

{% categoryDetail categoryLogo with name="Logo" id="5" %}
<img src="{{ categoryLogo }}" alt="指定分类标题" />

This is similar to the method of retrieving the article logo image, make sure to fill in thesrcandaltproperties correctly.

2. Get the Banner group image of the category

The Banner group image of the category is located incategoryDetailthe corresponding field in the tag isImages. Just like the article group image, it is also an array of image URLs.

{% categoryDetail categoryBanner with name="Images" %}
{% if categoryBanner %}
<div class="category-banner-slider">
    {% for bannerUrl in categoryBanner %}
    <img src="{{ bannerUrl }}" alt="分类Banner图片" />
    {% endfor %}
</div>
{% endif %}

Here, we getcategoryBannerImage list, and throughforLoop to display each image.

Flexible application: Use the image list as a background image.

Sometimes, we want the Banner image to be the background of a certain block, rather than direct<img>Label. At this point, we can obtain the first image of the group and apply it to the CSS style:

`twig {% categoryDetail category

Related articles

How to ensure that the old link traffic is not lost and the new content is displayed correctly after adjusting the page content structure, by using 301 redirect?

During the operation of a website, content updates, adjustments of the classification structure, or optimization of URL addresses are common operations.However, if not handled properly, these changes are likely to lead to a loss of website traffic and a drop in search engine rankings.幸运的是,AnQiCMS(AnQiCMS)内置了强大的301重定向功能,能够帮助我们平稳地度过这些调整期,确保旧链接的流量能够无缝过渡到新内容。Why 301 Redirects Are Indispensable?301 redirect, i.e., permanent transfer

2025-11-08

How to display different language versions and content on the front-end of a website through a language switcher based on user selection?

AnQi CMS is an efficient and customizable content management system that excels in multilingual support, allowing operators to easily build multilingual websites for global users.By cleverly utilizing its built-in features, we can build a flexible language switcher on the website front-end, accurately presenting different language versions of content based on user preferences, thereby effectively enhancing user experience and expanding market coverage.### Understanding the Core of Multilingual Support Implementing multilingual support in Anqi CMS is not just a simple text replacement, but a systematic workflow.

2025-11-08

How does AnQi CMS ensure that articles are automatically displayed on the website front end at the specified time?

In the fast-paced digital content world, how to ensure that content is accurately delivered to the target audience at the right time is a challenge faced by every content operator.Manual operation is not only inefficient but may also lead to release errors due to negligence.The timed release function of AnQiCMS (AnQiCMS) is specifically designed to address this pain point, providing an intelligent and automated way to ensure that your articles are displayed accurately on the website front end at the preset time points.### Understanding the core value of scheduled publishing For content operators, scheduled publishing is not just a convenient tool

2025-11-08

How to determine if a string or array contains a specific keyword in a template?

In the template development of Anqi CMS, we often need to dynamically adjust the page display based on specific attributes or text fragments of the content.Determine whether a string or array contains a specific keyword is a key step in implementing this dynamic logic.AnQiCMS is a powerful Django style template engine with built-in filters, making this operation very intuitive and efficient.## Core Tool: `contain` Filter The most direct way in AnQiCMS template system is

2025-11-08

How to use AnQiCMS template tags to display article lists on the page?

In AnQiCMS, flexibly displaying article lists on website pages is one of the core needs of website content management.Whether it is to build news dynamics, product display, blog articles, or any other content that needs to be presented in a list, the powerful template tag system of AnQiCMS can help you easily achieve it.This article will provide a detailed introduction on how to use the `archiveList` template tag, combining the various functions of AnQiCMS, to efficiently and beautifully present article lists on your website page.### Understand `archiveList`

2025-11-08

How to retrieve and display the detailed content of the current article in AnQiCMS

In AnQi CMS, to retrieve and display the detailed content of the current article, it mainly revolves around the organization of template files and built-in template tags.Understanding these core mechanisms allows you to flexibly control the presentation of articles on the frontend page. ### Core Concept: The Composition of Article Detail Page In AnQi CMS, the detailed content of each article is usually displayed through a specific template file.This template file will be automatically or manually called by the system according to the content model of the article (such as "Article Model" or "Product Model") and the settings in the background.By default

2025-11-08

How to set and display the TDK information (title, keywords, description) on the home page of AnQiCMS?

In website operation, TDK (Title, Description, Keywords) information is the foundation of Search Engine Optimization (SEO), especially for the homepage, its importance is self-evident.A clear and accurate homepage TDK can effectively help search engines understand the core content of the website, thereby improving the visibility and attractiveness of the website in search results.How can we conveniently and quickly set up and manage these key information in AnQiCMS and ensure that they are presented correctly to users?### One

2025-11-08

How does AnQiCMS achieve independent display of multi-site content under different domain names?

When using AnQiCMS to build and manage websites, users often face the need to create independent sites for different brands, businesses, or regions, and they also hope that these sites can be displayed independently under their respective domain names.AnQiCMS powerful multi-site management function, which is designed to solve this pain point.It allows users to easily create and operate multiple websites with independent content and domain names on the basis of a set of AnQiCMS core programs.### AnQiCMS The Core Concept of Multi-Site Management AnQiCMS

2025-11-08