How to display all related document lists under a specific `tagDataList` tag and support pagination?

Calendar 👁️ 68

In the daily content management of Anqi CMS, we often need to organize and display website content more flexibly.In addition to the traditional classification system, tags (Tag) provide us with another powerful way to associate content.It can aggregate documents of different categories but similar themes together, bringing users a more focused browsing experience.Today, let's delve deeply into a very practical template tag in Anqi CMS—tagDataListLook at how it helps us display all related document lists under a specific tag and easily implement pagination.

tagDataList: The core of tag document lists.

Imagine that your reader has developed a keen interest in a specific topic (tag) mentioned in an article after reading it, and hopes to see more content related to that topic.At this point, a well-designed tab page becomes particularly important.tagDataListTags are born for this, they can accurately capture all documents associated with a specific tag and present them to the user.

Basic usage: Quickly retrieve tag documents

If you are developing a tag detail page,tagDataListthe default usage is very concise. The system will intelligently recognize the tag ID of the current page and automatically load the documents under the tag:

{% tagDataList archives %}
    {# 循环遍历当前标签下的所有文档 #}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            <p>{{item.Description}}</p>
        </a>
    </li>
    {% empty %}
    <li>
        哎呀,这个标签下暂时没有找到相关文档哦!
    </li>
    {% endfor %}
{% endtagDataList %}

In the code above,archivesis a custom variable name that will carry fromtagDataListthe document list obtained. Inside the loop, eachitemrepresents a document, we can call itsTitle/Link/Descriptioncommon fields to display the content.

Of course, if you want to use non-tab pages or specify document lists with other tags, you cantagIdThe parameter explicitly specifies the tag ID:

{# 获取ID为5的标签下的文档列表 #}
{% tagDataList archives with tagId="5" %}
    {# ... 遍历文档内容 ... #}
{% endtagDataList %}

Combine pagination: Implement pagination browsing of tag document lists

For content-rich tags, it is obviously unrealistic to display all documents at once, at this point, the pagination feature becomes indispensable. AnQi CMS'stagDataListThe tab supports pagination perfectly, making your tab page both beautiful and practical.

To implement pagination,tagDataListthe tab needs to be paired withtype='page'Parameters to use, telling the system that we need a paged list. At the same time, throughlimitParameters to set how many documents are displayed per page. The other half of the pagination feature is bypaginationLabel to complete, it is responsible for generating page navigation.

Below is a complete example showing how to display a paginated document list in a tab.

{# tagDataList 标签,设置为分页模式,并指定每页10条文档 #}
{% tagDataList archives with type="page" limit="10" %}
    {# 循环遍历当前页的文档 #}
    {% for item in archives %}
    <div class="document-item">
        <a href="{{item.Link}}" class="document-link">
            <h5 class="document-title">{{item.Title}}</h5>
            <p class="document-description">{{item.Description}}</p>
            <div class="document-meta">
                <span>发布于:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>阅读:{{item.Views}}次</span>
            </div>
        </a>
        {% if item.Thumb %}
        <div class="document-thumb">
            <a href="{{item.Link}}">
                <img alt="{{item.Title}}" src="{{item.Thumb}}">
            </a>
        </div>
        {% endif %}
    </div>
    {% empty %}
    <div class="empty-state">
        哎呀,这个标签下暂时没有找到相关文档哦!
    </div>
    {% endfor %}
{% endtagDataList %}

{# 分页导航标签,'pages'是tagDataList传递过来的分页对象 #}
<div class="pagination-area">
    {% pagination pages with show="5" %}
        {# 首页链接,如果当前页是首页,添加'current'类名 #}
        <a class="pagination-link {% if pages.FirstPage.IsCurrent %}current{% endif %}" href="{{pages.FirstPage.Link}}">首页</a>
        {# 上一页链接,只有存在上一页时才显示 #}
        {% if pages.PrevPage %}
        <a class="pagination-link" href="{{pages.PrevPage.Link}}">上一页</a>
        {% endif %}
        {# 中间页码链接,遍历pages.Pages数组生成每个页码链接 #}
        {% for item in pages.Pages %}
        <a class="pagination-link {% if item.IsCurrent %}current{% endif %}" href="{{item.Link}}">{{item.Name}}</a>
        {% endfor %}
        {# 下一页链接,只有存在下一页时才显示 #}
        {% if pages.NextPage %}
        <a class="pagination-link" href="{{pages.NextPage.Link}}">下一页</a>
        {% endif %}
        {# 尾页链接,如果当前页是尾页,添加'current'类名 #}
        <a class="pagination-link {% if pages.LastPage.IsCurrent %}current{% endif %}" href="{{pages.LastPage.Link}}">尾页</a>
    {% endpagination %}
</div>

In this example,tagDataListtotypeis set to"page"andlimit="10"Specify displaying 10 documents per page.paginationThe tag is responsible for receivingtagDataListPass the pagination data (we name it here aspages), and according toshow="5"parameters, generate a navigation bar containing 5 page numbers, while automatically judging the current page and addingcurrentClass name, convenient for you to style

Related articles

How to effectively manage and display single-page content on a website using `pageList` and `pageDetail` tags?

In website operation, single-page content plays an indispensable role, it usually carries important information such as "About Us", "Contact Us", "Terms of Service", "Privacy Policy", etc., which needs to be clearly displayed and also requires convenient management.AnQiCMS provides the powerful template tags `pageList` and `pageDetail`, which help us efficiently manage and display these single-page content.

2025-11-08

How to retrieve and display the name, description, Banner image, and thumbnail of a specific category using the `categoryDetail` tag?

In AnQiCMS template creation, we often need to retrieve and display detailed information about specific categories, such as the name, description, and even preset Banner images and thumbnails.`categoryDetail` tag is born for this, it helps us easily extract this data from the database and flexibly display it on the website front end.

2025-11-08

How to use the `categoryList` tag to build a multi-level category navigation or display category lists in the content area?

In Anqi CMS, properly organizing website content categories is an important aspect for improving user experience and website maintainability.Whether it is to build a clear multi-level navigation menu, help users quickly locate information, or skillfully display different categories of content in the page content area, the `categoryList` tag is the core tool for realizing these functions. ### Core Tag: `categoryList` Description The `categoryList` tag is used specifically in the Anqi CMS template engine to retrieve the website category list.

2025-11-08

How do the `prevArchive` and `nextArchive` tags display the link and title of the previous/next document on the document detail page?

When we browse content on the website built with AnQiCMS, carefully crafted documents bring value to readers.It is particularly important to provide 'Previous' and 'Next' navigation links at the end of each article to make the reader's reading experience more smooth and encourage them to explore more relevant content.This can effectively guide users to deeply browse within the website, increase page visits and user stickiness, and is also very beneficial for the internal link structure and SEO optimization of the website.

2025-11-08

How to use the `navList` tag to create the main navigation menu of a website and support two-level dropdown display?

The main navigation menu of the website is an important entry for users to understand the content and structure of the website.The Anqi CMS provides a powerful and flexible `navList` tag, which helps us easily create and manage multi-level dropdown navigation menus, thus enhancing the user experience and clarity of the information architecture of the website. ### Step 1: Configure the navigation menu in the AnQi CMS backend Before starting to write template code, we need to set up the structure of the navigation menu in the AnQi CMS backend management system. 1.

2025-11-08

How to generate `breadcrumb` tags?

On a day when the content of a website is becoming richer, users often need to navigate between different pages on the website.To help visitors understand their current location and provide a convenient return path, breadcrumb navigation (Breadcrumb Navigation) has emerged.It is like a path indicator on a map, making it clear for the user to know 'Where I came from and where I am going to.'

2025-11-08

How to customize the content model of Anqi CMS to achieve diversified content display?

When building website content, we often find that various types of information have unique display requirements.A news article may require a title, author, publication date, and main content; a product introduction may cover name, model, price, inventory, and detailed parameters; and a case study may focus more on project name, client, solution, and result images.Traditional CMS systems often provide fixed and unchangeable content publication templates, which make it difficult to deal with diverse business scenarios and lack flexibility.

2025-11-08

How to set a unique display layout for different types of articles (such as news, products)?

In website operation, content is not just information itself, but also the way it is presented is equally important.Setting unique display layouts for different types of content (such as news, product introductions) can greatly enhance user experience, strengthen brand image, and even have a positive impact on search engine optimization (SEO).AnQiCMS (AnQiCMS) provides very flexible and powerful features in this aspect, allowing you to easily create exclusive visual styles for various types of content.

2025-11-08