How to retrieve the associated document list according to TagID in AnQiCMS?

Calendar 👁️ 65

Unlock content association: How to efficiently retrieve related document lists based on TagID in AnQiCMS

In a content management system, tags (Tag) are an important tool for connecting content, improving user experience, and optimizing search engine visibility.AnQiCMS, as an enterprise-level content management system developed based on the Go language, is well-versed in this field and provides flexible and powerful tag functions.For website operators, how to accurately obtain and display a list of associated documents based on a specific tag ID is a key link in the realization of refined content operation.Today, let's delve deeply into this practical feature of AnQiCMS, allowing you to easily navigate the associations between content, providing users with a richer exploration path.

The unique value of (Tag) in AnQiCMS

In AnQiCMS's design concept, tags are not just a simple classification of content, but more like bridges that organically link documents under different categories and even different content models (such as articles, products).Tags differ from categories in terms of hierarchy and exclusivity, they have high flexibility and aggregation.A document can belong to a category but can also be tagged with multiple tags, thus being discovered from multiple dimensions.For example, an article about "AnQiCMS Deployment Tutorial" may be tagged with "AnQiCMS", "Deployment", "Go Language", "Server Operations", and many other tags, greatly expanding the reach of the content.

The AnQiCMS tag management feature allows you to easily view, add, edit, and delete document tags. Each tag has fields such as name, index letter, custom URL, and description, and you can even set independent SEO titles and keywords for tags. This is crucial for building clear website themes and improving the ranking of specific keywords.

On the template level, AnQiCMS provides special tags for labels, such astagListUsed to get the tag list of all or specified documents on the website,tagDetailUsed to obtain detailed information about a specific tag. Today, we will focus ontagDataListthe tag, which is the core tool for obtaining the list of associated documents according to TagID.

Core: utilizingtagDataListLabel to get document list

When we need to retrieve all documents associated with a known tag ID,tagDataListTags are our first choice. They can accurately filter out all documents tagged with the provided TagID from the content library.

Let's understand its usage through a specific scenario. Assume you have a TagID of123The tag, possibly named "Go Language Development", now you want to display all articles related to "Go Language Development" on a page.

The basic calling method is very intuitive:

{% tagDataList archives with tagId="123" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            <p>{{item.Description}}</p>
            <div>
                <span>发布时间:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>浏览量:{{item.Views}}</span>
            </div>
            {% if item.Thumb %}
            <img src="{{item.Thumb}}" alt="{{item.Title}}">
            {% endif %}
        </a>
    </li>
    {% empty %}
    <li>
        该标签下暂无相关文档。
    </li>
    {% endfor %}
{% endtagDataList %}

In this code block,tagId="123"Tell AnQiCMS explicitly that we want to get all documents associated with the tag ID 123.archivesIt is a custom variable name that will carry the document list obtained. Then, we iterate over this list and can access{% for item in archives %}the document fields to build the display content.item.Title/item.Link/item.Description/item.CreatedTime/item.Views/item.Thumbetc.{% empty %}A block is a very considerate design, whenarchivesWhen the list is empty, it elegantly displays a prompt message to avoid blank pages or errors.

It is worth mentioning that if you are currently on a tag detail page (such astag/list.htmlortag/detail.htmlSuch a template file), AnQiCMS will automatically identify the TagID of the current page. In this case, you can even omit it.tagIdParameters to make the code more concise:

{% tagDataList archives %} {# 在标签详情页,会自动读取当前页面的 TagID #}
    {% for item in archives %}
    <li>
        {# 展示文档信息 #}
        <a href="{{item.Link}}">{{item.Title}}</a>
        <p>{{item.Description}}</p>
    </li>
    {% empty %}
    <li>
        当前标签下暂无相关文档。
    </li>
    {% endfor %}
{% endtagDataList %}

Advanced usage: combine other parameters for filtering and sorting

tagDataListThe power of tags is not limited to retrieving documents based on TagID, it also supports a series of parameters to help you finely control the retrieval and display of documents:

  • moduleId: Content model restrictionIf you only want to retrieve associated documents under a specific content model (such as "article model" or "product model"), you can usemoduleIdthe parameters. For example,moduleId="1"usually represents an article model. “`twig {% tagDataList articles with tagId=“123” moduleId=“1” %} {# Only display the document of the article model #} {% endtagDataList

Related articles

How to get the name, link, and description of a specified Tag?

As an experienced website operations expert, I know that effectively utilizing tags (Tags) in a content management system is crucial for the SEO, content organization, and user experience of the website.AnQiCMS (AnQiCMS) boasts powerful template functions and a flexible tag system, allowing you to easily display and manage these valuable information on the front end of the website.Today, let's delve deeply into how to accurately obtain the name, link, and description of a specified Tag in AnQiCMS, thereby providing stronger support for your content operation.In AnQiCMS

2025-11-07

How to display the details of a single Tag in AnQiCMS template?

As an experienced website operations expert, I am happy to give you a detailed explanation of how to flexibly and efficiently display the detailed information of a single Tag in AnQiCMS.AnQiCMS with its concise and efficient architecture provides powerful template customization capabilities for content operators.To deeply understand the presentation of individual Tag information, we first need to start with its template mechanism and core tags.How to display the details of a single Tag in AnQiCMS template?

2025-11-07

How to get the Tag list starting with a specific letter in AnQiCMS?

As an experienced website operation expert, I am happy to discuss the subtle aspects of AnQiCMS (AnQiCMS) in content operation with you.AnQiCMS with its efficient and customizable features, provides a powerful toolkit for content creators and operators.Today, let's delve into a specific and practical scenario: how to elegantly obtain a list of Tags starting with a specific letter in AnQiCMS, thereby achieving more refined content organization and display.

2025-11-07

How to display the AnQiCMS tag list by page number (limit)?

As an experienced website operations expert, I know that how to efficiently and flexibly display content in a content management system is the key to operational success.AnQiCMS with its concise and efficient architecture and powerful template tag system, provides us with great convenience.Today, let's delve into a common but crucial feature: how to implement pagination of the tag list by call quantity (limit) in AnQiCMS.

2025-11-07

How to display and sort the Tag document list with pagination?

As an experienced website operations expert, I know that the core value of a content management system (CMS) lies in its flexibility and fine control over content display.AnQiCMS (AnQiCMS) performs particularly well in this aspect, thanks to its efficient architecture based on the Go language and its rich set of features.For daily content operations, how to efficiently organize and display the document list under the tag (Tag), while providing friendly pagination and sorting features, is a key factor in improving user experience and website SEO performance.

2025-11-07

Does the AnQiCMS Tag tag support cross-content model usage?

## Boundary Breaking: How does AnQiCMS's Tag tag implement cross-content model management?As an experienced website operations expert, I know that the flexibility of the Content Management System (CMS) is crucial for efficient operation.AnQiCMS, with its efficient architecture based on the Go language and rich features, stands out in small and medium-sized enterprises and content operation teams.Amongst the seemingly basic yet extremely crucial function of "Tag Label", its design philosophy and application often reflect the depth and practicality of a CMS system.

2025-11-07

How to add a new document tag in the AnQiCMS backend management?

As an experienced website operations expert, I am well aware of the powerful and convenient content management capabilities of AnQiCMS.Label, this seemingly insignificant feature is actually a powerful tool for connecting content, enhancing user experience, and optimizing search engine performance.Today, let's delve into how to add new tags flexibly and efficiently to your documents in the AnQiCMS backend management.

2025-11-07

How to set SEO optimization (SEO title, keywords, description) for AnQiCMS Tag tags?

##驾驭AnQiCMS Tag: In-depth Analysis of SEO Optimization Settings (SEO Title, Keywords, Description) As an experienced website operations expert, I know that in today's fiercely competitive online environment, Search Engine Optimization (SEO) is the cornerstone of website success.AnQiCMS is an enterprise-level content management system developed based on the Go language, which has always attached great importance to SEO and considers it the cornerstone for enterprises and content operation teams.Today, we will delve into a powerful yet often overlooked SEO tool in AnQiCMS——Tag tag

2025-11-07