How can I display the list of articles under the category page and also show the category's Logo or Banner image at the same time?

Calendar 👁️ 79

In Anqi CMS, managing and displaying categorized content is a crucial step in building a structured, user-friendly website.The category page not only helps users quickly find the content they are interested in, but also, with carefully designed visual elements such as logos or banner images, it can effectively enhance the brand image and user experience.This article will detail how to implement these features on the Anqi CMS category page.


Understand the composition and template settings of the category page

In Anqi CMS, each category corresponds to a page that can display its content.To better control the layout and display effects of these pages, Anqi CMS provides a flexible template mechanism.When you want to display an article list and a unique Logo or Banner image for a specific category or all categories under a specific model, we need to pay attention to the template file of the category page.

The template files of AnQi CMS are usually stored in/templateIn the directory, following certain naming conventions. For category list pages, the commonly used template file naming format is:

  • {模型table}/list.html: This is the default list page template for all categories under the model.
  • {模型table}/list-{分类ID}.html:You can customize a dedicated list page template for a specific category ID.

This means you can use a list page template for the “Article” model (assuming its table name isarticle) for all categories.article/list.htmlOr it is specially designed for the "News Information" category with ID 10article/list-10.htmlIn the "Document Category" settings in the background, you can specify the template file to be used for each category.

Second, display the Logo or Banner image of the category on the category page

The Logo or Banner image is an important visual component of the category page.The Anqi CMS provides the function to upload these images for each category.You can go to the background and enter "Content Management" -> "Document Category", when editing a category, you will see the upload options for "Banner Image" and "Thumbnail".

In the template, we can usecategoryDetailtags to get the detailed information of the current category, including these images.

Get the category Logo or thumbnail:If your category is only set with one representative Logo or thumbnail, you can use it directly:LogoorThumbfield. Usually,Logofield is used to display the large image, whileThumbThe field is used for smaller thumbnails.

{# 假设这是分类列表页模板的某个位置 #}
<div class="category-header">
    {# 获取当前分类的Logo图,并将其用作页面标题的背景或直接展示 #}
    {% categoryDetail categoryLogo with name="Logo" %}
    {% if categoryLogo %}
        <img src="{{ categoryLogo }}" alt="{% categoryDetail with name='Title' %}" class="category-logo">
    {% endif %}

    {# 或者获取分类的缩略图 #}
    {% categoryDetail categoryThumb with name="Thumb" %}
    {% if categoryThumb %}
        <img src="{{ categoryThumb }}" alt="{% categoryDetail with name='Title' %}" class="category-thumbnail">
    {% endif %}

    <h1>{% categoryDetail with name='Title' %}</h1>
    <p>{% categoryDetail with name='Description' %}</p>
</div>

Display category Banner group images:If a category uploads multiple Banner images (in the "Banner Image" option in the backend), these images will be stored as a set of images. You can access them throughImagesField retrieval and use requiredforLoop to traverse and display.

{# 假设这是分类列表页模板的Banner区域 #}
<div class="category-banner-slider">
    {% categoryDetail bannerImages with name="Images" %}
    {% if bannerImages %}
        {# 遍历所有Banner图片 #}
        {% for imageSrc in bannerImages %}
            <div class="banner-item">
                <img src="{{ imageSrc }}" alt="{% categoryDetail with name='Title' %} - Banner {{ forloop.Counter }}">
            </div>
        {% endfor %}
        {# 如果只需要显示第一张Banner图作为固定头部背景 #}
        {% set firstBanner = bannerImages[0] %}
        <div class="fixed-banner" style="background-image: url('{{ firstBanner }}');"></div>
    {% endif %}
</div>

III, Display the list of articles under the category on the category page.

Displaying the list of articles under the category is the core function of the category page. Anqi CMS providesarchiveListThe tag makes it easy to achieve this requirement. This tag is very flexible and can filter articles based on various conditions, including categories and models.

On the category page, we usually want to retrieve all articles under the current category.archiveListTags automatically identify the category ID of the current page, so we usually do not need to explicitly specify it.categoryIdParameters, unless you want to get articles from other categories.

Basic article list display:The following code snippet shows how to get the list of articles under the current category and display the title, link, summary, and thumbnail of each article.

{# 假设这是文章列表区域 #}
<div class="article-list-section">
    {% archiveList articles with type="page" limit="10" %} {# type="page"表示启用分页,limit="10"表示每页显示10篇文章 #}
        {% for item in articles %}
            <div class="article-item">
                {% if item.Thumb %}
                    <a href="{{ item.Link }}" class="article-thumb">
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                    </a>
                {% endif %}
                <div class="article-content">
                    <h2 class="article-title"><a href="{{ item.Link }}">{{ item.Title }}</a></h2>
                    <p class="article-description">{{ item.Description }}</p>
                    <div class="article-meta">
                        <span>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                        <span>浏览量:{{ item.Views }}</span>
                    </div>
                </div>
            </div>
        {% empty %}
            <p>当前分类下暂无文章。</p>
        {% endfor %}
    {% endarchiveList %}
</div>

In the above code:

  • type="page"This is a key setting to enable pagination.
  • limit="10"It defines the number of articles displayed per page.
  • item.Thumb/item.Link/item.Title/item.DescriptionisarchiveListThe fields available for each article while iterating tags.
  • stampToDateThe filter is used to format the article's publish timestamp.

Four, implement the pagination function of the article list.

When the number of articles is large, pagination is an essential feature that can improve page loading speed and user experience. Anqi CMS provides pagination througharchiveListoftype="page"Combinepaginationtags.

paginationThe tag needs to be placed inarchiveListoutside the tag, and it needsarchiveListto pass the pagination data to it.

{# 承接上文的文章列表代码,在其下方添加分页部分 #}
<div class="pagination-section">
    {% pagination pages with show="5" %} {# show="5"表示最多显示5个页码按钮 #}
        <ul class="pagination-list">
            {# 首页按钮 #}
            <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}">
                <a href="{{ pages.FirstPage.Link }}">{{ pages.FirstPage.Name }}</a>
            </li>
            {# 上一页按钮 #}
            {% if pages.PrevPage %}
                <li class="page-item">
                    <a href="{{ pages.PrevPage.Link }}">{{ pages.PrevPage.Name }}</a>
                </li>
            {% endif %}
            {# 中间页码按钮 #}
            {% for pageItem in pages.Pages %}
                <li class="page-item {% if pageItem.IsCurrent %}active{% endif %}">
                    <a href="{{ pageItem.Link }}">{{ pageItem.Name }}</a>
                </li>
            {% endfor %}
            {# 下一页按钮 #}
            {% if pages.NextPage %}
                <li class="page-item">
                    <a href="{{ pages.NextPage.Link }}">{{ pages.NextPage.Name }}</a>
                </li>
            {% endif %}
            {# 末页按钮 #}
            <li class="page-item {% if pages.LastPage.IsCurrent %}active{% endif %}">
                <a href="{{ pages.LastPage.Link }}">{{ pages.LastPage.Name }}</a>
            </li>
        </ul>
        <p class="pagination-info">总计 {{ pages.TotalItems }} 篇文章,{{ pages.TotalPages }} 页,当前第 {{ pages.CurrentPage }} 页。</p>
    {% endpagination %}
</div>

here,pagesThe variable contains all the pagination-related data, such asTotalItems(Total number of articles),TotalPages(Total number of pages),CurrentPage(Current page) and links to each page (Link) and name (Name).

V, Integration and Practice Suggestions

To implement 'Display the list of articles under the category page and also show the category's Logo or Banner image', you can create a category namedarticle/list.html(or a specific category ID template) file, then integrate all the above code snippets into it.

Template file organization:

  1. Create in the template theme directory you have selected.article/list.htmlfile.
  2. Place the HTML structure, styles, and JavaScript code that you want to apply to all article category pages in this file.
  3. Insert the code above at the appropriate position in the file to display the category Logo/Banner image, article list, and pagination.

Backend configuration:

  1. Ensure your article is correctly categorized under the corresponding category and each article has uploaded a thumbnail (

Related articles

How to implement pagination for article lists, product lists, or Tag lists?

Managing website content, especially when the volume of content grows, how to allow visitors to quickly find the information they need while maintaining smooth page loading is an important issue.AnQiCMS (AnQiCMS) took this into full consideration from the outset of its design, providing a set of intuitive and powerful pagination features that allow your article list, product list, and even Tag list to display in an elegant pagination style.

2025-11-08

How to display a list of related articles based on the article's Tag (label)?

In a content management system, effectively utilizing tags (Tag) to organize and associate articles is a key factor in improving user experience and the efficiency of content discovery.AnQiCMS provides a powerful and flexible tag feature, allowing us to easily display related content lists based on the tags of the articles. ## Understanding AnQiCMS Tag Function AnQiCMS Tag function is not just for adding keywords to articles, it is more like a way to associate content across categories and models.By adding tags to the article, we can group those with similar themes

2025-11-08

How to display a list of friend links in the sidebar or footer area of a website?

AnQi CMS provides a set of intuitive and powerful features to help us easily manage website content.Among them, the link to friends is an important part of the external connection of the website, which not only helps the website's SEO performance, but also provides users with more valuable jump links.This article will provide a detailed introduction on how to flexibly display the friend links list in the sidebar or footer area of your website. ### Manage friend links in the background Before displaying the friend links on the website front end, we first need to configure them in the Anqi CMS backend.To manage the friend links, you can log in to the backend

2025-11-08

How to implement lazy loading of image content on article detail pages to improve page loading speed?

In today's fast-paced online environment, website loading speed is a key factor in user experience and search engine rankings.For an article detail page containing a large number of images, optimizing the image resources is particularly important.By implementing lazy loading of images, we can significantly improve the initial loading speed of the page, allowing visitors to see the content faster, thereby providing a better experience.The AnQiCMS (AnQiCMS) has fully considered the performance optimization needs of the website design, providing a simple and efficient way to achieve lazy loading of images on article detail pages.###

2025-11-08

How to display the global TDK (Title, Keywords, Description) information of the website?

## Optimizing Website Front: Display and Application of TDK Information in AnQi CMS In website operation, TDK (Title, Keywords, Description) is an indispensable basic element for Search Engine Optimization (SEO).They are like the 'business card' of a website, directly telling search engines about the theme, core content, and most important keywords of your page, thereby affecting the ranking and click-through rate in search results.

2025-11-08

How to precisely control the display content, level, and selected status of a website navigation menu?

Website navigation, like a signpost of a website, a clear and intuitive navigation system can greatly enhance the user experience and help visitors quickly find the information they need.At the same time, a good navigation structure is also crucial for search engines to understand the hierarchy of website content, to effectively crawl and rank.In AnQi CMS, we can flexibly and accurately control the display content, level, and selected status of the website navigation, making it both beautiful and practical.

2025-11-08

How to add and display dynamic breadcrumb navigation on a webpage?

In modern web design, breadcrumb navigation plays a crucial role.It is like a 'footprint' of the user on the website, clearly showing the position of the current page in the overall website structure, making it easy for visitors to understand, thereby greatly enhancing the usability and user experience of the website.At the same time, a reasonably set breadcrumb navigation also helps search engines better understand the structure of the website, which is very beneficial for SEO optimization.For users who use AnQiCMS to manage websites

2025-11-08

How to create and display custom single-page content (such as About Us, Contact Information)?

In website operations, content such as 'About Us', 'Contact Information', and 'Privacy Policy' is usually displayed in the form of independent pages. This content is relatively fixed and plays an important role in the website structure.AnQiCMS (AnQiCMS) provides an intuitive and powerful set of features for creating and managing these custom single-page applications, allowing you to easily publish and update without writing code. ### Create Custom Single Page Content Creating a single page in Anqi CMS is a simple and direct process.Firstly, you need to log in to the back-end management interface. 1. **Enter the page management

2025-11-08