How to display a category thumbnail (`item.Thumb`) or Banner image (`item.Logo`) next to the category list?

Calendar 👁️ 62

As an experienced website operations expert, I am well aware of the importance of the visual presentation of website content for user experience and information communication.In a powerful and flexible system like AnQiCMS, we have multiple ways to achieve fine-grained control over content, especially in key navigation areas such as category lists. How to effectively display category thumbnails or Banner images is an important factor in enhancing the professionalism and attractiveness of the website.Today, let's delve into how to ingeniously integrate these visual elements into the category list in Anqi CMS.


AnQiCMS Practical Guide: Display thumbnails or Banner images elegantly next to the category list

In the navigation design of a website, the category list is not just a pile of text, but it is also a key entry point for users to quickly understand the website structure and find content of interest. Adding representative visual elements to the category list, whether it is a small thumbnail (item.ThumbIs it more attractive Banner imageitem.LogoIt can greatly enhance user experience, making the website interface more vivid and lively, and the information transmission more intuitive.AnQi CMS provides great flexibility, making all this easy and efficient.

Backend configuration: Add visual elements to categories

In AnQi CMS, the operation to set thumbnails or Banner images for categories starts from the content management backend. The system reserves a dedicated image upload area for each category, and you can complete the configuration with just a few easy steps:

  1. Log in to the Anqi CMS backend: Log in to your website management interface.
  2. Navigate to category management: Find 'Content Management' in the left menu and click on 'Document Category'.
  3. Select or create a categoryYou can edit an existing category or create a new one.
  4. Upload imageIn the category editing page, scroll down to the "Other Parameters" section. Here, you will see the "Banner Image" and "Thumbnail" options.
    • ThumbnailThis is usually used in list or card displays as a small representative image. It is recommended to upload images of moderate size and clear content.
    • Banner image: These are usually larger, more visually striking images that can serve as the top banner of a category page or as the main visual element in a category list in some layouts.The system supports uploading multiple Banner images, but please note that the image dimensions should be consistent to ensure a unified and beautiful display effect.
  5. Save ChangesAfter uploading, be sure to click Save to ensure that your image settings take effect.

Through such configuration, the classified data includes the URLs of these visual elements, waiting for us to call them in the front-end template.

Front-end display: unlock the visual power in the template.

AnQi CMS uses a template engine syntax similar to Django, which makes it intuitive and easy to understand to call category data in front-end templates. We mainly use this to display these images next to the category list.categoryListTemplate label.

When we use{% categoryList categories ... %}Such a label loops to output categories,categorieseach variable initemrepresenting a category will includeitem.Thumbanditem.LogoThese properties correspond to the thumbnail and Banner image URLs you upload on the backend.

Here are some key calling tips and注意事项:

  • Directly access the propertyInforloop, you can access it directly through{{ item.Thumb }}or{{ item.Logo }}To get the image address.
  • Conditional judgment: Not all categories need or will upload images. To avoid exceptions in page display caused by empty image links, it is strongly recommended to use{% if item.Thumb %}or{% if item.Logo %}Perform a conditional judgment, only render the image tag when the image exists.
  • Choose the appropriate image: Decide where to display the category list based on your design requirements.item.Thumb(更适合紧凑布局) oritem.Logo(More suitable for highlighting visual effects or as a Banner). It can also be used together, for example, displaying thumbnails first, and if not available, try to display the Logo.
  • addaltpropertyTo optimize for SEO and accessibility, it is necessary to<img>tagsaltset the content as the title of the category{{ item.Title }}.

Complete example: Freshen up the category list

Now, let's demonstrate how to elegantly display category images next to a category list using a specific template code example:

{# 假设我们想获取ID为1的文章模型下的所有顶级分类 #}
{% categoryList categories with moduleId="1" parentId="0" %}
    <ul class="category-list-with-images">
        {% for item in categories %}
            <li class="category-item">
                <a href="{{ item.Link }}" class="category-link">
                    <div class="category-content">
                        {# 优先展示缩略图,如果存在 #}
                        {% if item.Thumb %}
                            <img src="{{ item.Thumb }}" alt="{{ item.Title }} 缩略图" class="category-thumb">
                        {# 如果没有缩略图,但存在Banner图,则展示Banner图 #}
                        {% elif item.Logo %}
                            <img src="{{ item.Logo }}" alt="{{ item.Title }} Banner图" class="category-banner-fallback">
                        {% else %}
                            {# 如果没有任何图片,可以显示一个占位符或者默认图标 #}
                            <span class="no-image-placeholder">🎨</span>
                        {% endif %}
                        <h3 class="category-title">{{ item.Title }}</h3>
                        <p class="category-description">{{ item.Description }}</p>
                    </div>
                </a>
            </li>
        {% else %}
            {# 如果没有任何分类 #}
            <p>暂无分类数据。</p>
        {% endfor %}
    </ul>
{% endcategoryList %}

In this code, we first usecategoryListThe tag obtained the specified model(moduleId="1") under all top-level categories(parentId="0")). Then,forIn the loop, we create a list item for eachitem(category) created a list item.

The key point is{% if item.Thumb %}and{% elif item.Logo %}Judgment logic. It ensures that:

  1. If the category has uploaded a thumbnail (item.Thumb) it is displayed first.
  2. If there is no thumbnail but there is an uploaded Banner image (item.Logo) then display the Banner image as an alternative.
  3. If both images are not available, a simple text placeholder is displayed to avoid the embarrassment of whitespace on the page or failed image loading.

By such logic, you can flexibly display visual elements next to the category list based on the actual image upload situation, while also considering the beauty and robustness of the page.

A温馨提示 with **practice

  • Image optimizationMake sure to compress and optimize the size of the image before uploading.The 'Content Settings' in AnQi CMS backend provides functions such as 'whether to enable Webp image format', 'whether to automatically compress large images', and more, which can help you automate image processing and speed up page loading speed.
  • Responsive DesignIn CSS styles, add responsive styles forcategory-thumborcategory-banner-fallbackand other image classes, such as `max-width:

Related articles

Can the `categoryList` tag display the number of documents under each category? How can `item.ArchiveCount` be retrieved and displayed?

As an experienced website operation expert, I know that how to efficiently and intuitively display content data in a content management system is the key to improving user experience and content operation efficiency.AnQiCMS (AnQiCMS) offers us great flexibility with its simple and efficient architecture.Today, let's delve deeply into a question that both operators and template developers are very concerned about: Can the `categoryList` tag display the number of documents under each category?How to get and display `item.ArchiveCount`?” --- ##

2025-11-06

How can you determine if a category has a subcategory? How can the `item.HasChildren` field be applied to conditional judgments?

As an experienced website operations expert, I deeply understand the importance of efficiently using template tags in the daily application and content strategy formulation of AnQiCMS (AnQiCMS).Today, let's delve deeply into a very practical topic in website structure construction: how to determine whether a category (Category) contains subcategories, and how to cleverly use the `item.HasChildren` field in templates to achieve intelligent content display.

2025-11-06

What do `categoryList` loop's `item.Title` and `item.Link` represent, and how to output?

As an experienced website operations expert, I know that how to efficiently and accurately extract and display data in a content management system is the cornerstone of website success.AnQiCMS is an enterprise-level content management system based on the Go language, and its simple and efficient template engine is very appealing to me.Today, let's delve deeply into what `categoryList` loop's `item.Title` and `item.Link` represent in AnQiCMS template development, and how we can elegantly present them in the template.### Reveal

2025-11-06

How do I correctly use the `all=true` parameter of `categoryList` to display all categories in the sidebar?

In Anqi CMS, efficiently managing and displaying website content is the key to operational success.The sidebar acts as an important navigation area for websites, often needing to display clear categories to guide users quickly to the information they need.When you want to display all categories in the sidebar and are puzzled by the `all=true` parameter of the `categoryList` tag, this is exactly the topic we will delve into today.In AnQi CMS, categories are the framework for organizing website content.

2025-11-06

What is the actual use of the `item.Spacer` field in multi-level category display, and how to beautify the prefix?

As an experienced website operations expert, I know that every seemingly minor feature in a content management system may play a key role in user experience and content presentation.Today, let's delve deeply into a frequently overlooked but indispensable field in AnQiCMS, which is essential for building a clear and hierarchical content structure - `item.Spacer`.

2025-11-06

How to highlight the category link being accessed according to the `item.IsCurrent` field?

As an experienced website operations expert, I know that user experience is the foundation of website success.How to help visitors quickly locate their current position on a content-rich website and clearly understand the navigation structure is the key to improving user satisfaction.Today, let's delve deeply into a very practical and elegant feature of Anqi CMS - how to cleverly highlight the current category link accessed using the `item.IsCurrent` field, thereby significantly optimizing the navigation experience of the website.

2025-11-06

Can the `categoryList` tag return the `item.Description` field for SEO description on the category page?

In website operation, the SEO description (Meta Description) of the category page is one of the key elements to improve search engine ranking and click-through rate.A well-written description that not only accurately summarizes the page content but also attracts users to click.For website administrators and content operators using AnQiCMS, how to efficiently and accurately utilize the system functions to manage these descriptions is a common issue.Today, let's delve deeply into a specific issue: `categoryList` tag returns the `item'

2025-11-06

How `categoryList` and `archiveList` work together to display the latest few documents under each category?

As an experienced website operations expert, I am well aware of the powerful aspects of a content management system (CMS), not only in terms of its backend functionality, but also in the flexibility of its frontend content display.AnQiCMS (AnQi CMS) is exactly such an outstanding tool, based on the high-performance architecture of the Go language,配合 its concise and efficient template tag system, it allows us to easily handle various complex content display needs. Today

2025-11-06