How to accurately retrieve related documents based on `tagId` for the `tagDataList` tag?

Calendar 👁️ 59

As an experienced website operation expert, I have a deep understanding of the powerful content management capabilities of AnQiCMS (AnQiCMS).In daily operation, the fine organization and efficient distribution of content are the key to improving user experience and SEO performance.Today, we will delve into a very practical template tag in AnQiCMS—tagDataListLet's see how it helps us based ontagIdAccurately obtain relevant documents to better build a content ecosystem.

Flexible content aggregation: understandingtagDataListThe core value

In AnQiCMS, tags (Tag) are one of the important dimensions for organizing content, and they are more flexible and horizontally correlated than traditional categories (Category).When a user enters an aggregated page through a tag, or we want to recommend related tag content at the bottom of the article, we need a mechanism to accurately retrieve all documents associated with that tag.tagDataListThe tag is born for this. It allows us to display related documents scattered across various categories and models based on a specific tag ID, greatly enriching the internal links of the website content and the user discovery path.

Accurate positioning:tagIdMagic

tagDataListThe core of tags lies in itstagIdParameters. Each tag created in the AnQiCMS backend will have a unique numeric ID. ThistagIdis like the 'ID card' of the content, through which,tagDataListCan find all documents tagged with this specific label accurately, like a navigator.

To usetagDataListThe basic syntax structure is:

{% tagDataList archives with tagId="1" %}
    {# 在这里循环输出与tagId为1的标签关联的文档 #}
{% endtagDataList %}

In this example,archivesIt is a custom variable name that will carry all the document data obtained.tagId="1"It clearly tells the system that we want to retrieve all documents associated with the tag ID 1.

It is worth mentioning that if you are developing a label detail page (such as/tag/某个标签别名ThentagDataListthe label will be very intelligent. In this case, even if you do not explicitly specifytagIdIt also tries to automatically read the current page's tag ID, thus automatically displaying all documents related to the current tag, saving the trouble of manually obtaining the ID.

Beyond the Basics: ExploretagDataListMore advanced features

In addition to the basictagIdLocation,tagDataListAnd provides a series of parameters to make content acquisition and display more flexible and powerful:

  • moduleId: Content model restrictionIn AnQiCMS, content can belong to different models, such as article models, product models, etc. If you only want to retrieve documents under a specific tag of a particular model (for example, only displaying articles and not displaying products), you can usemoduleIdthe parameters. For example,moduleId="1"Used to retrieve documents under the article model.

  • order: Controls sorting methodThe display order of documents is crucial for user experience.tagDataListSupports various sorting rules, such as:

    • order="id desc": The documents are sorted by document ID in descending order, usually meaning the most recently published documents are listed first.
    • *order="views desc": The documents are sorted by view count in descending order, with popular documents displayed first.
    • order="sort desc": Displayed according to the custom sorting set in the background.
  • limitwithtype="page": Implement elegant paginationWhen there are many documents under a tag, loading them all at once will affect page performance and user experience.tagDataListCombinelimitandtype="page"Parameters can easily implement pagination.limitDefine the number of documents to display per page, andtype="page"then indicates that this is a pagination list, which needs to be used in conjunction with the AnQiCMS pagination tagspaginationUse. You can also uselimit="2,10"in the form, starting from the second item, get 10 data to achieve more fine-grained offset control.

  • siteId: Multi-site content sharingFor users who have deployed multiple AnQiCMS sites,siteIdThe parameter allows you to call documents under specified tags across sites, which is very useful when building a content matrix for multiple sites.

Get document details: rich content display

BytagDataListEach document obtained (inforusually represented byitemIndicate), they all contain rich properties that can be used to display on the front-end page:

  • item.Id:Document ID
  • item.Title:Document title
  • item.Link: Document detail page link
  • item.Description: Document introduction
  • item.Thumboritem.Logo: Document thumbnail or cover image
  • item.Views: Document views
  • item.CreatedTime: Document creation time (timestamp, needs to be paired withstampToDateFormat
  • item.CategoryId: Document category ID (can be used withcategoryDetailtags to get category information

Be sure to use when displaying the date{{stampToDate(item.CreatedTime, "2006-01-02")}}This formatting function converts timestamps into a readable date format.

Practical exercise: A comprehensive example.

Assuming we are building a detail page for the label "Go Language", hoping to display all the articles under the label, and implement pagination, while displaying the title, summary, category, publication time, view count, and thumbnail of the articles.

”`twig {# Firstly, use tagDetail to get the title and description of the current tag for use in page TDK or title display #} {% tagDetail currentTag with name=“Title” %} {% tagDetail tagDescription with name=“Description” %}

Label: {{ currentTag }}

{{ tagDescription }}

{# 使用tagDataList获取当前标签下的文档列表,并按浏览量降序,每页显示10条,开启分页功能 #}
{% tagDataList archives with type="page" order="views desc" limit="10" %}
    {% for item in archives %}
    <article class="document-item">
        <a href="{{ item.Link }}" title="{{ item.Title }}">
            {% if item.Thumb %}
            <div class="document-thumbnail">
                <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
            </div>
            {% endif %}
            <div class="document-content">
                <h2>{{ item.Title }}</h2>
                <p class="document-description">{{ item.Description }}</p>
                <div class="document-meta">
                    {# 获取文档所属分类的标题和链接 #}
                    <span>分类:
                        {% categoryDetail docCategory with name="Title" id=item.CategoryId %}
                        {% categoryDetail docCategoryLink with name="Link" id=item.CategoryId %}
                        <a href="{{ docCategoryLink }}">{{ docCategory }}</a>
                    </span>
                    {# 格式化文档发布时间 #}
                    <span>发布时间:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                    <span>浏览量:{{ item.Views }}</span>
                </div>
            </div>
        </a>
    </article>
    {% empty %}
    <p>该标签下暂无相关文档。</p>
    {% endfor %}
{% endtagDataList %}

{# 分页导航区域,配合tagDataList的type="page"使用 #}
<div class="pagination-area">
    {% pagination pages with show="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 %}">
            <

Related articles

How to display the list of all documents associated with the Tag on the Tag detail page?

In content operation, tags (Tag) are the key tools for connecting content, enhancing user experience, and optimizing search engine optimization (SEO).A well-designed Tag detail page that not only allows users to quickly find related content of interest, but also clearly communicates the organization structure and thematic relevance of the website's content to search engines.AnQi CMS as an efficient and flexible content management system provides strong and intuitive support in this aspect, allowing content operators to easily achieve fine-grained content operation.

2025-11-07

How to get the SEO title and description information of a specified Tag using the `tagDetail` tag?

As an experienced website operations expert, I know that in today's highly competitive digital environment, every detail can affect the visibility and user experience of a website.AnQiCMS (AnQiCMS) provides powerful tools for our refined operation with its high efficiency, flexibility, and SEO-friendly features.Today, let's delve deeply into a very practical template tag in AnQi CMS, `tagDetail`, and see how it helps us accurately obtain and optimize the SEO title and description information of the specified Tag (label) page.

2025-11-07

How to create an independent Tag detail page in AnQiCMS ( `tag/index.html` )?

## Create an independent Tag detail page in AnQiCMS (`tag/index.html`) As an experienced website operations expert, I fully understand the great potential of tags (Tag) in content organization and Search Engine Optimization (SEO).A well-designed tag page that not only helps users find relevant content quickly but also brings valuable long-tail traffic to the website.AnQiCMS as an enterprise-level content management system based on the Go language excels in providing efficient and customizable content management solutions

2025-11-07

How to implement a hot tag cloud effect using `tagList` in AnQiCMS?

In the surge of digital content operation, Tag Cloud, as a direct and efficient way of information aggregation, has always been favored by website operators and users.It can not only help users quickly find the key content of the website, but also effectively improve the website's SEO performance, guide the spider to crawl, and increase the page PV.As an experienced website operations expert, I deeply understand the strong and flexible tag management capabilities of AnQiCMS (AnQi CMS).

2025-11-07

Does AnQiCMS's Tag document list (`tagDataList`) support filtering by content model?

As an experienced website operation expert, I am willing to deeply analyze the `tagDataList` tag filtering function in AnQiCMS.Today, being able to flexibly organize and present content is crucial for improving user experience and optimizing SEO.AnQiCMS on this aspect, with its powerful content model and tag management features, provides us with many conveniences.

2025-11-07

How to implement document sorting and pagination display on the Tag document list page?

AnQi CMS is an efficient and flexible content management system, and its Tag feature is an important way to organize and discover content.When a user visits a specific Tag page, they often expect to see all documents related to that Tag, and these documents should be presented in an orderly and easy-to-browse manner.This involves how to implement document sorting and pagination display on the Tag document list page.

2025-11-07

How to apply the `tagDetail` tag's 'Logo' field on the Tag detail page?

As an experienced website operations expert, I am well aware of how to fully utilize each field in a content management system to transform it into an effective tool that attracts users and enhances the value of the website.AnQiCMS (AnQiCMS) with its flexible and versatile characteristics, provides us with a lot of room to maneuver.Today, let's talk about the `tagDetail` tag, which has a seemingly ordinary but limitless potential field - 'Logo', and see how it shines on the Tag detail page.

2025-11-07

How to customize AnQiCMS's Tag detail page template (`tag/list.html`)?

As an old veteran in website operation for many years, I know that every detail of a page may affect the overall performance of the website, especially in SEO and user experience.AnQiCMS is an efficient and flexible content management system that provides us with powerful customization capabilities, allowing us to make each page unique.

2025-11-07