How to display thumbnails, descriptions, and custom fields on the document list page?

Calendar 👁️ 58

In website operation, the content list page is a key link for users to obtain information and decide whether to delve deeper into browsing.A rich information, clear layout list page, which can greatly enhance user experience and content attractiveness.It is particularly important to display thumbnails, descriptions, and custom fields reasonably in the document list page of Anqi CMS to achieve this goal.

By using the powerful and flexible template tag system provided by Anqi CMS, you can easily meet this requirement without complex programming knowledge, just by making simple modifications and configurations to the template files.

Basic Preparation: Customization and Filling of the Content Model

Before starting to modify the template, make sure that your content is correctly configured and filled in the background. Thumbnails, descriptions, and custom fields must be set when publishing or editing the document.

  1. ThumbnailIn the document publication or editing page of AnQi CMS, you will see an area named "Document Image".This is where you set the document thumbnail. You can upload a carefully selected image as a thumbnail.It is worth mentioning that even if you do not manually upload, if the document content contains images, the system will intelligently extract the first image as a thumbnail to ensure the visual integrity of the list page.

  2. descriptionThe "Document Summary" column is used to enter the abstract or overview of the document.A concise, attractive description can effectively stimulate users' desire to click.Even if you choose to leave it blank, AnQi CMS will automatically extract the first part of the document text as a summary.However, we usually recommend writing manually to better control the expression of information, highlighting key selling points or content highlights.

  3. Custom fieldThe flexible content model of AnQi CMS is one of its core advantages.In the "Content Management" -> "Content Model", you can add exclusive custom fields for different content types (such as articles, products) according to your business needs.For example, you can add fields such as 'price', 'brand', 'inventory', etc. to the product model, or add fields such as 'author', 'source', 'publish date' to the article model.These custom fields will be displayed in the "Other Parameters" area during document editing, waiting for you to fill in.Please make sure that you have defined and filled in these fields according to your actual needs, as they are an important source of rich information display on the list page.

Core Implementation: Document List TagarchiveListapplication

To display the above information on the document list page (such as article list page or product list page), we mainly rely on the Anqi CMS.archiveListTemplate tag. This tag is the core of data retrieval and output, it can obtain document data from the database and provide it for the template.

Generally, the template files for the list page are locatedtemplate/{您的模板目录}/{模型table}/list.html. You need to use these files.archiveListTags to loop through and display each document.

The following is the code structure for implementing thumbnails, descriptions, and custom field display.

{# 假设这是您的文档列表页面模板 #}
<div class="document-list">
    {% archiveList archives with type="page" limit="10" %}
        {% for item in archives %}
            <div class="document-item">
                <a href="{{ item.Link }}" class="document-link">
                    {# 1. 展示缩略图 #}
                    <div class="document-thumb">
                        {% if item.Thumb %}
                            <img src="{{ item.Thumb }}" alt="{{ item.Title }}" loading="lazy">
                        {% else %}
                            {# 如果没有缩略图,可以显示一个默认图片或占位符 #}
                            <img src="{{ system.TemplateUrl }}/images/default-thumb.jpg" alt="{{ item.Title }}" loading="lazy">
                        {% endif %}
                    </div>

                    <div class="document-info">
                        <h2 class="document-title">{{ item.Title }}</h2>

                        {# 2. 展示描述 #}
                        {% if item.Description %}
                            <p class="document-description">{{ item.Description|truncatechars:150 }}</p> {# 截取前150个字符并添加省略号 #}
                        {% endif %}

                        {# 3. 展示自定义字段 #}
                        <div class="document-meta">
                            {% archiveParams params with id=item.Id %}
                                {% for param in params %}
                                    {# 假设您自定义了"作者"和"产品型号"字段 #}
                                    {% if param.FieldName == "author" %}
                                        <span class="meta-item">作者:{{ param.Value }}</span>
                                    {% elif param.FieldName == "productModel" %}
                                        <span class="meta-item">型号:{{ param.Value }}</span>
                                    {% elif param.FieldName == "someRichText" %}
                                        {# 如果是富文本字段,需要使用 |safe 过滤器确保HTML正确渲染 #}
                                        <div class="meta-item-richtext">{{ param.Value|safe }}</div>
                                    {% endif %}
                                    {# 您可以根据实际定义的自定义字段FieldName,添加更多的条件判断和展示逻辑 #}
                                {% endfor %}
                            {% endarchiveParams %}
                        </div>
                    </div>
                </a>
            </div>
        {% empty %}
            <p>目前没有可显示的文档。</p>
        {% endfor %}
    {% endarchiveList %}

    {# 如果您使用了 type="page" 进行分页,别忘了添加分页代码 #}
    {% pagination pages with show="5" %}
        {# 分页导航 HTML 代码 #}
    {% endpagination %}
</div>

Code parsing and key points:

  • {% archiveList archives with type="page" limit="10" %}This is the core tag for retrieving document lists.
    • archivesIt is a variable name used to store the retrieved document list data.
    • type="page"It indicates enabling pagination functionality to cooperate.pagination.
    • limit="10"Set the display of 10 documents per page.
  • {% for item in archives %}: Loop througharchivesEach document in the list,itemRepresents the current document object being cycled through.
  • Thumbnail (item.Thumb):{{ item.Thumb }}Directly output the thumbnail URL of the document. To optimize user experience, we added aloading="lazy"attribute to make the image lazy load and improve page loading speed. At the same time, through{% if item.Thumb %}Check if there is an abbreviation

Related articles

How to manage and display all documents in AnqiCMS and support filtering by title, model, and category?

In the era of explosive digital content, efficiently managing and displaying website documents is a core challenge for every operator.When you have a vast amount of articles, product descriptions, service instructions, or any form of site content, how to ensure that these contents are organized, easy to find, and can be filtered according to different needs, is directly related to user experience and operational efficiency.AnqiCMS, as a system specially designed for enterprise content management, provides a powerful and flexible solution in this aspect.

2025-11-07

How to dynamically display the list of articles or products under a category in the navigation dropdown menu?

AnQi CMS: Build dynamic dropdown navigation menus to make content easily accessible In website operation, the navigation menu is the starting point for users to explore website content, and it is also an important clue for search engines to understand the website structure.The traditional navigation menu is often fixed links, when the website content becomes increasingly rich, especially when there are many articles and product types, manually maintaining the content list in the dropdown menu becomes particularly繁琐 and prone to errors.The AnQi CMS provides us with an elegant and efficient solution with its powerful content management capabilities

2025-11-07

How to judge the current link status in the navigation list tags and add a highlight style?

In website operation, clear navigation is a key factor in improving user experience.When users can intuitively see their location on the current page, it not only reduces the sense of being lost but also improves the professionalism and usability of the website.Adding a highlight style to the current link in the navigation bar is a very effective way to achieve this goal.In Anqi CMS, highlighting the current link of the navigation item is actually simpler and more direct than you imagine.

2025-11-07

How to create and manage a website navigation menu and implement the display of secondary navigation?

The website's navigation menu, like the skeleton and landmark of the website, guides visitors to quickly find the information they need, and is the core of user experience and website information architecture.A clear and intuitive navigation system not only enhances user satisfaction, but is also crucial for search engine optimization (SEO).AnQiCMS was designed with this in mind from the outset, providing a flexible and easy-to-operate navigation menu management function, allowing website operators to easily build and maintain the navigation system of the website.

2025-11-07

How to accurately retrieve and display the content of a specified ID or URL alias on the document detail page?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides users with a rich set of tools to build and manage websites.During website operations, we often need to precisely display the detailed content of a document on a specific page, whether it is the document being viewed on the current page or specified by a particular identifier (such as ID or URL alias).The template tag system of Anqi CMS, especially the `archiveDetail` tag, is the key to meeting this requirement.

2025-11-07

How to use the `archiveDetail` tag to display images, view counts, and publishing time on the document detail page?

In website operation, the document detail page is the core area that attracts users and conveys information.A rich content, intuitive detail page, which can not only significantly improve user experience, but also has a positive push on search engine optimization (SEO).AnQiCMS provides a powerful `archiveDetail` tag that allows us to easily obtain and display various document information, such as images, view counts, and publication time.Next, we will explore how to skillfully use the `archiveDetail` tag in the document detail page

2025-11-07

How to correctly render Markdown content as HTML and display mathematical formulas and flowcharts in the Anqi CMS template?

The content is the soul of the website, and how to present these contents efficiently and beautifully is a topic of concern for every operator.In AnQi CMS, using Markdown to write content not only greatly improves writing efficiency, but also easily achieves complex layout requirements, such as inserting mathematical formulas and drawing flowcharts. This is undoubtedly a powerful feature for technical blogs, educational websites, or corporate websites that need to display complex business processes.Next, we will explore how to correctly render Markdown content as HTML in the Anqi CMS template

2025-11-07

How to use the `archiveList` tag to display a document list according to specified conditions (such as latest, most popular, recommended attributes)?

AnQiCMS is an efficient and flexible content management system that provides a variety of content display methods, among which the presentation of the document list is a very core part of website operation.We hope to dynamically display the latest articles, the most popular content, or carefully recommended high-quality documents on the homepage, category pages, or thematic aggregation pages according to different operational objectives.All of this can be easily achieved through the powerful `archiveList` tag of AnQiCMS

2025-11-07