How to use AnQiCMS tags to display the document list under a specific Tag?

Calendar 👁️ 70

In AnQiCMS, a tag (Tag) is a powerful content organization method that can help us associate content more flexibly across different categories and models.Properly utilizing tags can not only optimize the website's SEO performance but also significantly improve the user's content discovery experience on the website.When we want to focus on displaying all relevant documents under a specific tag, AnQiCMS provides a set of intuitive and efficient template tags to meet this need.

This article will introduce in detail how to easily display the document list under a specific tag on the website front-end page using the built-in template tags of AnQiCMS.

Understand the 'Tag' in AnQiCMS

In the AnQiCMS backend, we can manage all the tags of the website through the 'Document Tags' feature under the 'Content Management' menu.Each tag can have its own name, index letter, custom URL, SEO title, and description.When we release articles or products, we can add one or more related tags to the content.These tags act like keywords for the content, connecting related content scattered across different categories to form a thematic aggregation page.

For example, if your website has articles about "Go language tutorials" and "Go language project practice", they may belong to different categories.If all are tagged with "Go Language", then when users visit the "Go Language" tag page, they can see all related content, which greatly facilitates information search.

Core feature: usetagDataListTag displays the document list

AnQiCMS provides a namedtagDataListA dedicated tag used to retrieve and display a list of documents under a specific tag from the database. This tag is typically used in the front-end template files of a website, such as the tag list page (tag/list.html) Or Label Home Page (tag/index.html) Of course, you can also call it at any needed location.

tagDataListThe basic usage is as follows:

{% tagDataList archives with tagId="1" type="page" limit="10" %}
    {% for item in archives %}
        {# 在这里显示文档的标题、链接、简介等信息 #}
    {% empty %}
        {# 如果没有找到文档,显示此内容 #}
    {% endfor %}
{% endtagDataList %}

Let's interpret it in detailtagDataListLabel Key Parameters and Usage:

tagDataListLabel Main Parameters:

  • tagIdThis is the core parameter for specifying which tag's document list you want to display. You can directly enter the tag's numeric ID (such astagId="1")
    • Tip:If you are on an AnQiCMS automatically generated tag detail page (such astag/list.htmlortag/index.htmlUsed intagDataList, usually it can be omittedtagIdparameters. The system will intelligently identify the tag ID of the current page and automatically retrieve the documents under the tag.
  • moduleIdIf you only want to display documents under a specific content model (such as "article model" or "product model"), you can use this parameter. For example,moduleId="1"Indicates that only the document of the article model is displayed.
  • limit: Controls the number of documents displayed. For example,limit="10"Up to 10 documents will be displayed.
  • type: Defines the display type of the list.
    • type="list"(Default): Simply lists the specified number of documents without providing pagination functionality.
    • type="page": Enable pagination functionality, usually in conjunction withpaginationTags are used together.
  • order: Set the sorting method for documents. Common ones include:
    • order="id desc": Sort by ID in descending order (newest release).
    • order="views desc": Sort by views in descending order.
  • siteIdIf you have enabled the multi-site feature and want to retrieve data from other sites, you can use this parameter. Generally, it does not need to be filled in.

Within the loopitemAvailable fields:

In{% for item in archives %}the loop,itemRepresents each document object, you can access multiple properties to display document information:

  • item.Id: Document ID.
  • item.Title: The document title.
  • item.Link: Document detail page link.
  • item.Description: Document description.
  • item.Thumb: Document thumbnail address.
  • item.CreatedTime: Document publishing time (timestamp format, needs to be usedstampToDateFiltered formatting()).
  • item.Views: Document views.
  • item.CategoryId: Document category ID. You can also get its category name and link through thecategoryDetailtag.
  • and also other fields customized in the content model.

Practice session: Step-by-step implementation of Tag document list display

Next, we will demonstrate through several specific scenarios.tagDataListactual application.

Scenario one: Display the document list under the current tag on the Tag detail page (with pagination)

Assuming you are editing the template file for the tag detail page (for exampletemplate/您的模板目录/tag/list.htmlortemplate/您的模板目录/tag/index.html)。On this page, AnQiCMS will automatically recognize the tag being accessed.

{# 首先,您可能需要显示当前标签的一些信息,如标签名称和描述 #}
<h1>标签:{% tagDetail with name="Title" %}</h1>
<p>简介:{% tagDetail with name="Description" %}</p>

<div class="tag-documents">
    <h2>相关文档</h2>
    {% tagDataList archives with type="page" limit="10" %} {# type="page" 启用分页,每页显示10篇 #}
        {% for item in archives %}
            <article class="document-item">
                <h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
                <p class="description">{{ item.Description }}</p>
                {% if item.Thumb %}
                    <a href="{{ item.Link }}" class="thumb">
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                    </a>
                {% endif %}
                <div class="meta">
                    <span>发布于: {{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                    <span>阅读量: {{ item.Views }}</span>
                    <span>分类: <a href="{% categoryDetail with name='Link' id=item.CategoryId %}">{% categoryDetail with name='Title' id=item.CategoryId %}</a></span>
                </div>
            </article>
        {% empty %}
            <p>抱歉,当前标签下暂无文档。</p>
        {% endfor %}
    {% endtagDataList %}

    {# 别忘了添加分页导航,让用户可以浏览更多页面 #}
    <div class="pagination-container">
        {% pagination pages with show="5" %} {# 最多显示5个页码按钮 #}
            <ul>
                {% if pages.PrevPage %}
                    <li><a href="{{ pages.PrevPage.Link }}">上一页</a></li>
                {% endif %}
                {% for pageItem in pages.Pages %}
                    <li {% if pageItem.IsCurrent %}class="active"{% endif %}><a href="{{ pageItem.Link }}">{{ pageItem.Name }}</a></li>
                {% endfor %}
                {% if pages.NextPage %}
                    <li><a href="{{ pages.NextPage.Link }}">下一页</a></li>
                {% endif %}
            </ul>
        {% endpagination %}
    </div>
</div>

In this example, `{% tagDataList archives with type=“page” limit=“1”}

Related articles

How to display the list of related documents in AnQiCMS, what is the logic?

How to effectively guide users to discover more interesting content in a content management system is the key to improving user experience and website depth.AnQiCMS handles the 'related document list' feature by providing a flexible and intelligent mechanism that allows us to easily display other articles or products closely related to the current content on the website. This not only helps to extend the user's stay on the website but also optimizes the search engine crawling efficiency through internal links.### AnQiCMS

2025-11-08

How to display custom field content on the AnQiCMS document detail page?

When managing website content in AnQiCMS, we often encounter the need to add some unique information for different types of documents (such as articles, products, etc.).AnQi CMS provides flexible content model features, allowing us to customize fields to meet these personalized needs.How can these custom fields be displayed on the document detail page of the website after they are created and filled with data? This is actually simpler than you imagine, AnQiCMS's powerful template tag system provides us with various convenient ways to achieve this.--- ###

2025-11-08

How to implement the display of previous and next document links in AnQiCMS templates?

When browsing website content, users often want to be able to navigate easily between related articles.In order to find more information or simply enjoy a smooth reading experience, the "Previous" and "Next" document links play a crucial role.They can not only effectively increase the user's stay time on the website, reduce the bounce rate, but also have a positive impact on the internal link structure of the website and the search engine optimization (SEO), helping search engines better understand the relevance of the website content.### Core Function Analysis: AnQiCMS

2025-11-08

How to use the AnQiCMS document list tag to display content for specific categories or recommended attributes?

In AnQi CMS, efficiently managing and displaying website content is the key to improving user experience and website operation effectiveness.Whether you want to display the latest articles of a specific category on the homepage or highlight products with the "recommended" attribute, the document list tag (`archiveList`) provided by AnQiCMS is the core tool to meet these needs.Its flexible parameter configuration allows us to accurately control content retrieval, transforming technical details into easily accessible operational strategies.

2025-11-08

How to display user comment lists and implement pagination in AnQiCMS?

In website content operation, user comments are an important part of enhancing interactivity and activity, and reasonable pagination can ensure that the comment list is both complete and loads smoothly.AnQiCMS (AnQiCMS) provides powerful and flexible template tags, allowing you to easily display and manage user comments on the front-end page, and implement pagination functionality for the comment list.

2025-11-08

How to retrieve and display custom form fields in AnQiCMS comment form?

When using AnQiCMS to manage website content, the online message function is undoubtedly an important means of interacting with visitors, collecting feedback, or gathering potential customer information.In addition to the basic name, contact information, and message content, we often need to collect more specific and personalized information, such as 'Your project budget', 'The type of service you are interested in', or 'The expected contact time'.AnQi CMS provides a flexible custom message field function, allowing us to easily meet these needs.How can I retrieve and elegantly display these custom form fields on the website front page?

2025-11-08

How to display pagination links in AnQiCMS and control the number of page numbers displayed?

In website operation, effectively managing and displaying a large amount of content is the key to improving user experience.When the content list is too long, a reasonable pagination mechanism can not only make it easier for users to browse, but also optimize the page loading speed, and indirectly improve the search engine friendliness.In AnQiCMS, implementing pagination and flexibly controlling the display quantity of page numbers is a relatively direct and powerful process.--- ## Display pagination links elegantly and flexibly control the number of pages in AnQiCMS In your AnQiCMS website, when the number of articles, products, or other list content increases

2025-11-08

How to set and display the global information of AnQiCMS, such as Logo, filing number, and copyright?

AnQiCMS provides an intuitive and powerful way to manage and display the global information of the website, such as the website logo, filing number, and copyright statement.This information is not only an important part of the website's brand image, but also concerns the legal and compliant operation of the website.The detailed introduction on how to set and utilize these global information will follow. ### Set global information in the background All the global information of the website is concentrated in the "Global Function Settings" of AnQiCMS backend.

2025-11-08