How to retrieve and loop through all document lists under a specific Tag (label) in the template?

Calendar 👁️ 79

In AnQi CMS, content organization can not only be achieved through traditional classification methods, but also the flexible "Tag" mechanism provides a wide space for content association and user search.When you want to display all documents under a specific tag in a certain area of the website, such as the sidebar, related recommendation module, or even a dedicated Tag aggregation page, Anqi CMS provides powerful and intuitive template tags to make this process effortless.

This article will deeply explore how to use simple code in Anqi CMS templates to retrieve and loop through the list of all documents under a specific Tag (label), helping you better utilize the tag feature to enhance the organization of website content and user experience.

The role of (Tag) in AnQi CMS

In AnQi CMS, tags are a flexible content organization tool.Tags can cross different content models (such as articles, products, etc.) to associate with different content.This means an article about the 'AnQi CMS User Manual' and a product of 'AnQi CMS Training Service' can be tagged with 'AnQi CMS'.This flexibility allows content to be associated and discovered from multiple dimensions, greatly enriching the website's navigation and SEO potential.

Core weapon:tagDataListTag

To obtain the document list under a specific Tag, we mainly rely on the provided by AnQi CMStagDataListTemplate tag. This tag is specifically used to retrieve a collection of documents associated with a specific tag from the database.

tagDataListBasic structure of the tag

tagDataListThe use of tags conforms to the common syntax of AnQi CMS template engine, it requires a variable name to carry the obtained document list, and define the loop output logic between a pair of{% tagDataList ... %}and{% endtagDataList %}.

Basic syntax is as follows:

{% tagDataList 变量名称 with 参数 %}
    {% for item in 变量名称 %}
        {# 在这里输出文档的各项信息 #}
    {% endfor %}
{% endtagDataList %}

Among them,变量名称Can be any name you customize, for example,archives/tagArticlesetc.itemIt isforThe temporary variable representing each document in the loop.

Key parameter parsing

tagDataListTags support multiple parameters, allowing you to finely control which documents under which Tags to retrieve, as well as how to sort and display them.

  • tagId(Required):This is the key parameter you want to get under which Tag of the document. You can directly enter the numeric ID of the Tag, for exampletagId="1". If you are on a Tag detail page (such astag/list.html) Use this tag and you want to retrieve the documents under the current page Tag, you do not need to specifytagId, it will automatically read the Tag ID of the current page.
  • moduleId(Optional):If you only want to retrieve documents associated with a specific model (such as an article model, product model) under this Tag, you can use this parameter. For example,moduleId="1"It indicates that only the documents under the article model should be retrieved.
  • type(Optional):Controls the display style of the list.
    • type="list"(Default): BylimitThe number of documents to display as specified by the parameter, without pagination features.
    • type="page":

Related articles

How does AnQiCMS define and display related articles? Is it based on keywords or manual association?

In website operation, recommending relevant articles is an important strategy to enhance user experience, extend user stay time, and optimize on-site SEO.AnQiCMS provides a flexible and efficient mechanism to define and display related articles, allowing operators to choose between intelligent recommendations or manual association according to their actual needs. ### Smart Recommendation: Dynamic Association Based on Keywords and Tags The smart recommendation mechanism of AnQiCMS mainly relies on the keywords and tags set in the article content. When you edit articles in the background, you can set: * **Document keywords

2025-11-08

How to dynamically fetch and display the previous and next articles of the current article on the article detail page?

In website operation, how to allow users to smoothly jump to related or the next article after reading an article is the key to improving user experience and website stickiness.Especially for sites with a large amount of content, such as blogs, information stations, or product display websites, a intuitive 'Previous/Next' navigation function is particularly important.It can not only guide users to deeply browse and reduce the bounce rate, but also provide more internal links for search engines to optimize the SEO performance of the website.AnQiCMS (AnQiCMS) is a powerful content management system that fully considers this need

2025-11-08

How to retrieve the custom fields (such as author, source, additional parameters) of the current article and display them?

In Anqi CMS, managing and displaying custom fields for articles such as authors, sources, or additional parameters is a common and practical need in content operation.The Anqi CMS, with its flexible content model design, provides multiple ways to achieve this goal, helping you easily enrich article information and present it to readers in a personalized manner. ### Understanding AnQi CMS Custom Fields Firstly, we need to understand how article custom fields work in AnQi CMS.

2025-11-08

How to obtain and display the title, content, thumbnail, and other core information of an article on the article detail page?

When operating a website, the article detail page is the key entry point for users to understand the core value of the content.A well-designed, comprehensive article detail page that not only improves user experience but also effectively helps search engines understand the content of the page, thus optimizing the website's SEO performance.AnQiCMS (AnQiCMS) provides a powerful and flexible template tag system that allows you to easily obtain and present all the core information of the article.

2025-11-08

How to retrieve and display detailed information of a specified category, including its description, Banner image, and Logo?

In a content management system, categories are not only the form of content organization, but also the core of website structure and user navigation.Flexibly obtain and display detailed information of a specific category, such as its description, unique banner image and logo, which is crucial for creating attractive and informative pages.AnQiCMS (AnQiCMS) provides an intuitive and powerful template tag to meet this need, allowing you to easily achieve this requirement.### Core Function Tag

2025-11-08

How to implement a multi-level nested tree structure display in the category list?

When building website categories, we often need to display a clear, hierarchical structure so that users can intuitively understand the ownership of the website content.AnQiCMS provides powerful template tag features, fully supporting the display of multi-level nested tree structures in category lists, helping you easily create a user-friendly navigation system.The core of achieving this effect lies in the clever use of the `categoryList` template tag of Anqi CMS and its built-in hierarchical judgment function.By looping in the template, you can use the parent-child relationship of the category

2025-11-08

How to display the main category in the navigation bar and show the latest products under this category in the dropdown menu?

In website operation, a clear and effective navigation system is the key to improving user experience and website professionalism.AnQiCMS (AnQiCMS) with its flexible content management and powerful template engine, can help us easily achieve complex navigation requirements.Today, let's discuss how to display the main categories in the website's navigation bar and also show the latest products under the category in a dropdown menu when the mouse hovers over it.### One, Understand the navigation and content management basics of AnQiCMS One of the core advantages of AnQiCMS lies in its modular content management system

2025-11-08

How to get and loop through all independent pages in AnQiCMS template (such as About Us)?

In AnQi CMS, sometimes we need to list some independent pages in the website's navigation bar, footer, or other specific areas, such as "About Us", "Contact Us", "Privacy Policy", and so on.These pages usually contain fixed content and do not belong to a specific category or article model. AnQiCMS refers to them as 'single pages'.Fortunately, AnQiCMS provides a very intuitive and powerful template tag that can easily retrieve and loop through information for these single pages.### Core Tag

2025-11-08