How to get all associated documents under a specific Tag using the `{% tagDataList %}` tag?

Calendar 👁️ 53

Deep analysis of AnQi CMS: How to use it cleverly{% tagDataList %}Label precise aggregation of content?

In the world of content operation, tags (Tag) are the bridges connecting content to users.It not only helps us better organize and classify massive amounts of information, but also significantly improves the efficiency of content discovery and the SEO performance of websites.For users of AnQiCMS, fully utilizing its powerful tag function is a key step in achieving refined content operation.Today, let's delve into a highly practical template tag in Anqi CMS -{% tagDataList %}Understand how it helps us retrieve all associated documents under a specific tag, thereby building a more attractive and valuable content aggregation page for users.

Tag, the intelligent index of content management

In AnQi CMS, tags are not just simple keywords.It represents a flexible content association mechanism that allows content to cross traditional classification boundaries, aggregating multidimensionally based on themes, keywords, or characteristics.From adding one or more tags to the content when you publish documents in the background, to finally intelligently linking the documents tagged with the same tag on the frontend page, Anqi CMS provides seamless and efficient support.As mentioned in the document, the "Document Tag Management" of Anqi CMS can view and manage all document tags.The document tags are not categorized by type and model, the same tag can be assigned to documents of different content models at the same time, which gives the content great flexibility and interconnectivity.

{% tagDataList %}: Conductor of tag content

When we talk about how to get all related documents under a specific tag{% tagDataList %}The tag is undoubtedly the core tool for this task. It can filter and return all documents associated with the specified tag ID (usually referred to as "archive" in AnQiCMS).The strength of this tag lies in its flexibility and controllability, allowing you to accurately display content according to different business needs.

Let's interpret it in detail{% tagDataList %}Usage and its main parameters:

A glimpse at the basic usage:

{% tagDataList archives with tagId="1" %}
    {# 循环遍历文档内容 #}
{% endtagDataList %}

Here, archivesIs a variable name you define, used for storage{% tagDataList %}The document list returned by the tag.

Detailed explanation of core parameters, grasp the pulse of content acquisition:

  1. tagId: Specify the unique identifier of the tag

    • This is{% tagDataList %}The most core parameter. When you are on the detail page of a tag (such astag/list.htmlortag/index.html), Anqi CMS will intelligently identify the Tag ID of the current page, at this time you do not need to explicitly pass intagIdThe parameter will automatically retrieve and use the current page's Tag ID to query the document.
    • However, if you want to display content under a specific tag on other pages, such as a module on the homepage, the sidebar of an article detail page, or an independent special topic page, you need to manually go throughtagId="[Tag ID]"Specify the label ID you want to retrieve the content for. For example, to retrieve all documents under the "Marketing" label with ID 5, you can usetagId="5".
  2. moduleId: Limit the scope of the content model

    • The AnQi CMS supports flexible content models, such as the "article model" (usuallymoduleId="1"), and the "product model" (usuallymoduleId="2")et al. If you only want to get the label-related documents under a specific model, you can usemoduleId="[模型ID]"to filter. For example,moduleId="1"it will only return the documents under the 'Article Model', ensuring the accuracy of the content.
  3. orderDefine the sorting method of the content

    • The order in which content is presented is crucial for the user's browsing experienceorderThe parameter allows you to customize the sorting rules of the document. Common sorting methods include:
      • order="id desc": Sorted in descending order by document ID, usually meaning the most recently published documents are at the top.
      • order="views desc"Sort the documents by the number of views in descending order, displaying the most popular documents.
      • order="sort desc": Arrange in descending order according to the custom sorting value on the back end, allowing you to manually adjust the priority of important content.
  4. limit: Control the number of documents displayed.

    • This parameter is used to limit the number of documents returned each time a query is made. For example,limit="10"only 10 documents will be displayed.
    • It is worth mentioning,limitIt also supports the "offset mode", which islimit="[起始偏移量],[数量]"For example,limit="2,10"Indicates starting from the second document (index starting from 0), retrieving the next 10 documents, which is very useful in some special layouts.
  5. type: Switch the display type of the list

    • typeThe parameter defines the way the list is presented.
      • type="list"It is the default value, it will return directly.limitThe parameter specifies the number of document lists.
      • type="page"It means you want to build a paginated document list. When usingtype="page"When,you also need to combine AnQi CMS's{% pagination %}tags to render pagination navigation,providing a better browsing experience for users.
  6. siteId:Data isolation in a multi-site environment

    • For users of the security CMS deployed on multiple sites,siteIdThe parameter ensures that you can call across sites or limit the call to the current site.In most cases, if you only manage one site, you do not need to fill in this parameter, the system will handle it by default.

Traverse the document object to extract the required information:

{% tagDataList %}The tag will take the collection of obtained documents as an array object (we name itarchivesReturn. You can use{% for item in archives %}to iterate over each document object. Eachitemrepresents an independent document and contains rich field information, such as:

  • item.Id:Document ID
  • item.Title:Document title
  • item.Link:Document link
  • item.Description: Document introduction
  • item.Logooritem.Thumb: Document cover image or thumbnail
  • item.CreatedTime: Document publication time (usually needs to be配合{{stampToDate(item.CreatedTime, "2006-01-02")}}Format
  • item.Views: Document views
  • item.CategoryId: Document category ID

etc., you can flexibly call according to your actual needs.

Practice exercise: A typical Tag list page template example

Assuming we are building a Tag detail pagetag/list.htmlI hope to display all articles under this tag and support pagination. Below is a simplified but complete example code:

"twig {# Page TDK settings, ensure SEO friendly #} {% tdk seoTitle with name=\"Title\" siteName=true %} {% tdk seoKeywords with name=\"Keywords\" %} {% tdk seoDescription with name=\"Description\" %} <!DOCTYPE html>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ seoTitle }}</title>
<meta name="keywords" content="{{ seoKeywords }}">
<meta name="description" content="{{ seoDescription }}">
<link rel="stylesheet" href="{% system with name='TemplateUrl' %}/css/style.css">

{# 引入公共头部 #}
{% include "partial/header.html" %}

<div class="container">
    {# 面包屑导航,提升用户体验 #}
    {% breadcrumb crumbs %}
    <nav class="breadcrumb">
        {% for item in crumbs %}
            <a href="{{ item.Link }}">{{ item.Name }}</a>
            {% if not forloop.Last %} &gt; {% endif %}
        {% endfor %}
    </nav>
    {% endbreadcrumb %}

    <h1 class="tag-title">标签:{% tagDetail with name="Title" %}</h1>

Related articles

How to get detailed information about a specific Tag using the `{% tagDetail %}` tag, such as description and custom URL?

As an experienced website operations expert, I am well aware of the importance of tag management for website content organization and search engine optimization.In AnQiCMS (AnQiCMS), a tag is not only a tool for content classification, but also a bridge connecting user interests with website content.Today, let's delve into how to make full use of the powerful template tag `{% tagDetail %}`, accurately obtain the detailed information of a specific tag, especially its description content and custom URL, so as to better serve the operation and SEO of the website.### Getting to know `{

2025-11-06

How to retrieve and display a specified number of document tag lists using `{% tagList %}` tags?

As an experienced website operations expert, I have accumulated rich experience in the practical application of content management systems, especially AnQiCMS (AnQiCMS).I deeply realize that efficient content operation is inseparable from in-depth exploration and flexible application of system functions.Today, we will focus on a powerful and commonly used tag in the AnQiCMS template - `{% tagList %}`, discussing how to cleverly use it to retrieve and display a specified number of document tag lists to optimize the website's content layout and user experience.### Label

2025-11-06

How should the 'document label' and 'document classification' be selected and matched in content organization?

In the daily operation of AnQiCMS (AnQiCMS), how to organize content efficiently and systematically is a problem that every operator needs to think deeply about.Among them, 'Document Classification' and 'Document Tag' are two core content organization tools, although their purposes are similar, their design concepts and application scenarios are quite different.Correctly understand and use them, not only can it significantly improve the user experience of the website, but it can also lay a solid foundation for SEO optimization.

2025-11-06

How to add Tag tags for articles and products in the AnQiCMS background?

As an experienced website operations expert, I am well aware of the importance of tags (Tag) in content management and search engine optimization.AnQiCMS as an efficient and flexible content management system, its built-in tag function provides great convenience for operators.Today, let's delve into how to easily and efficiently add Tag tags to your articles and products in the AnQiCMS backend, and transform them into a powerful tool to enhance the value of your website.

2025-11-06

What are the specific benefits of custom URL settings for document tags in SEO?

As an experienced website operations expert, I know that every detail of optimization can bring significant traffic growth and brand enhancement to the website.In AnQiCMS (AnQiCMS), such a powerful and SEO-friendly content management system, fully utilizing its various features is the key to success.Today, let's delve deeply into a seemingly minor but actually profound feature: the specific benefits of custom URL settings for document tags in SEO.

2025-11-06

How to add, edit, and delete document tags in the AnQiCMS backend management interface?

As an experienced website operations expert, I fully understand that how to efficiently organize and manage content in a content management system is crucial for the healthy development of a website.AnQiCMS, with its powerful functions and flexible customization, has provided us with many conveniences, among which the management of document tags is an indispensable part of content operation.Labels can not only help users find related content quickly, but are also an important tool to improve website SEO performance and content aggregation capabilities. Today

2025-11-06

Does the document tag support marking and management across content models (such as articles and products)?

In the ever-changing field of digital marketing, the efficient organization and management of website content is the foundation of success.As an expert who has been deeply involved in website operations for many years, I am well aware of the importance of a flexible and powerful content management system (CMS) for improving operational efficiency and user experience.AnQiCMS (AnQiCMS) has won a good reputation in the industry with its excellent performance and rich features.Today, we will delve deeply into a key issue often mentioned in content operation: Does Anqi CMS support tagging and management across content models?## SecureCMS: Label

2025-11-06

How to implement the `{% tagList %}` tag to retrieve its associated tags by document ID?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system, whose powerful template tag system is the key to enabling personalized display for content operators and website developers.Today, we will delve into one of the very practical tags: `{% tagList %}`, especially how to skillfully use it to accurately retrieve and display the associated tags based on the document ID.This is crucial for building a content-rich, highly connected website.

2025-11-06