How to display the list of all documents under a specific Tag?

Calendar 👁️ 60

In AnQi CMS, managing and displaying content, the tag (Tag) is undoubtedly a very flexible and powerful tool.It can help us classify content in multiple dimensions, not only convenient for visitors to find topics of interest, but also effectively improve the website's SEO performance.Today, let's delve deeply into how to elegantly display the list of all documents under a specific tag (Tag) on your website.

Backend preparation: Make sure the tags are set properly

Before the front-end display begins, we need to make sure that the background tag settings are complete and standardized.

Firstly, you can go to the Anqi CMS backend.Content Managementarea, findDocument TagModule. Here, you can create, edit, and manage all the tags of the website.It is recommended to set a clear 'label name' and meaningful 'label introduction' for each tag, which helps optimize the SEO of the tag page.

Secondly, when you publish or edit a document (whether it is an article or a product), be sure to add relevant tags in the "Tag label" field.You can choose an existing tag or directly enter a new one.Only when documents are associated with tags can they be effectively aggregated and displayed on the front end.

The core feature is revealed: Understanding the wonder of template tags

The Anqi CMS provides powerful and easy-to-use template tags, allowing us to flexibly call various content on the front-end. For the document list under the tags, we will mainly use the following key tags:

  • tagDetailUsed to obtain detailed information about a specific tag, such as tag ID, title, description, and link. This is very useful when building the header information of a tab page.
  • tagList: Used to retrieve a list of tags, for example, to display all tags associated with a document or to display all popular tags on a website.
  • tagDataList:This is the main character of today!It is specifically used to retrieve the list of all documents under a specified tag.

To display the document list under a specific Tag,tagDataListThe tag is indispensable. It provides rich parameters, allowing you to precisely control the filtering, sorting, and display of content:

  • tagId: This is the core parameter to specify which document label you want to display. If you are currently on a label detail page (for example,tag/list.htmlortag/index.htmlSuch a template), the system will automatically recognize the current pagetagIdAt this time, you can omit this parameter. If it is called on other pages (such as the homepage, category pages, etc.), you need to specify it explicitlytagId.
  • moduleId: If your website uses a different content model (such as article model, product model, etc.), you can specify this parameter to only display documents under a specific model. For example,moduleId="1"This is usually used to retrieve the document of the article model.
  • type: This parameter determines the type of the list.type="list"It will simply list a specified number of documents, whiletype="page"it will generate a document list with pagination features.
  • limit: Used to control the number of documents displayed per page or per call. For examplelimit="10"It will display 10 documents.
  • order: Defines the sorting method of the documents, you can sort by publish time (order="id desc"), views (order="views desc")or custom sorting in the background(order="sort desc")etc. for setting。“
  • siteId: If you manage multiple sites and want to call data from other sites, you can specify the site ID through this parameter。“

Practice exercise: Use tags to display document lists in templates

Now, let's see how to use specific code examples to apply them in different scenariostagDataList.

Scene one: Display all documents under the current tag on the tag list page (tag/list.html)

When a user clicks on a tag, it usually jumps to a dedicated tag list page. On this page,tagDataListThe tag will automatically identify the tag ID of the current page, without us manually entering ittagId. At the same time, in order to provide a better user experience, we usually add pagination features.

Assuming your template file istag/list.htmlThe code structure may look like this:

”`twig {# Get the details of the current tag for use in the page title and description #} {% tagDetail currentTag with name=“Title” %} {% tagDetail tagDescription with name=“Description” %}{{currentTag}} - {% system with name=“SiteName” %}

Label: {{currentTag}}

{{tagDescription}}

{# 使用 tagDataList 获取当前标签下的文档列表,并启用分页 #}
{% tagDataList archives with type="page" limit="10" order="id desc" %}
    {% for item in archives %}
    <article class="document-item">
        <h2><a href="{{item.Link}}">{{item.Title}}</a></h2>
        {% if item.Thumb %}
            <div class="document-thumbnail">
                <a href="{{item.Link}}"><img src="{{item.Thumb}}" alt="{{item.Title}}"></a>
            </div>
        {% endif %}
        <p class="document-description">{{item.Description}}</p>
        <div class="document-meta">
            <span>发布日期: {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
            <span>浏览量: {{item.Views}}</span>
        </div>
    </article>
    {% empty %}
    <p>当前标签下暂时没有文档。</p>
    {% endfor %}
{% endtagDataList %}

{# 添加分页导航 #}
<div class="pagination-area">
    {% pagination pages with show="5" %}
        <ul>
            {% if pages.FirstPage %}
            <li><a class="{% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a></li>
            {% endif %}
            {% if pages.PrevPage %}
            <li><a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a></li>
            {% endif %}
            {% for item in pages.Pages %}
            <li><a class="{% if item.IsCurrent %}active{% endif %}" href="{{item.Link}}">{{item.Name}}

Related articles

How to configure and display the article Tag tag list in AnQi CMS?

In website operation, Tag tags (also known as keyword tags) are a very practical way to organize content, which can help users quickly find related content and also improve the SEO effect of the website content.AnQiCMS (AnQiCMS) provides a comprehensive Tag label configuration and display function, making it easy and efficient to manage and display these tags.Below, let's take a detailed look at how to set up and use these tags in AnQiCMS.--- ### One, background configuration and management of article Tag label In AnQiCMS

2025-11-08

How to display the user message or article comment list and handle the review status?

In website operation, user comments and article reviews are an important part of promoting interaction and enhancing content value.For users of Anqi CMS, it is crucial to display user-generated content reasonably and manage their review status effectively to ensure the quality of website content and user experience.We will discuss in detail how to achieve this goal in Anqi CMS. ### Learn about comment and message management in Anqi CMS Anqi CMS provides users with convenient content comment and website message management features.In the background management interface

2025-11-08

how to display the captcha in the message or comment function?

In website operation, the message and comment functions are important channels for interaction with users, but they often become hotbeds of spam and malicious flooding.It is particularly important to add captcha to these interactive functions to maintain a clean and high-quality communication environment.AnQi CMS understands this and provides a convenient solution for it.How can you display a captcha in the Anqi CMS message or comment feature to effectively resist spam?This mainly consists of two core steps: first, enable the captcha feature in the background, and then integrate the captcha element into the front-end template.### Step 1

2025-11-08

How to display the website's friend link list on the front end?

In website operation, friendship links play an indispensable role.They not only help improve the quality of a website's external links, enhance search engine optimization (SEO) effects, but also bring additional traffic to the website and increase its credibility through peer recommendations.Our CMS understands the importance of friendship links, therefore, it provides an intuitive and convenient management function, and supports flexible front-end display methods, allowing website administrators to easily present these important cooperative resources on the page.### One, Friendship Link Management in AnQi CMS In the AnQi CMS backend management interface

2025-11-08

How to filter and display a list of documents with specific titles or categories in content management?

Today, as content management is increasingly becoming the core competitiveness of corporate websites, AnQiCMS (AnQiCMS) helps us easily manage a large amount of content with its flexible and efficient features.When you need to accurately filter and display a list of documents with specific titles, categories, or attributes, AnQiCMS provides intuitive and powerful template tags to make this process simple and efficient.### Core Tool: `archiveList` Tag Overview To display the document list on the website front-end, we mainly use AnQiCMS's core template tags

2025-11-08

How to display Markdown formatted content on a front-end page (including mathematical formulas and flowcharts)?

AnQi CMS provides users with powerful and flexible content management capabilities, among which the support for Markdown format greatly improves the efficiency of content creators.Whether it is necessary to display complex mathematical formulas in technical articles or to present clear flowcharts in product documents, Anqi CMS can help you beautifully present these contents on the frontend page. To achieve this goal, we need to follow several steps, from backend settings to frontend template adjustments, to ensure that the content is correctly parsed and rendered.### First step: Enable Markdown editor in the background First

2025-11-08

How to configure URL rewrite rules in AnQi CMS to optimize link display?

The website link, like the door number of a website, a clear and regular door number is not only convenient for visitors to remember and share, but also a key to understanding the structure of the website content, improving the efficiency of inclusion and ranking for search engines.This technique of optimizing dynamic links to look like static files is called 'pseudo-static'.The Aanqi CMS thoroughly understands this, providing users with powerful and flexible static configuration capabilities, aimed at helping websites perform better in search engines while improving the user browsing experience.The value of pseudo-static: Why can't it be ignored?in website operation

2025-11-08

How to avoid XSS attacks and safely display HTML content when outputting?

In website content management, ensuring the safe display of information, especially in preventing cross-site scripting (XSS) attacks, is an important issue that every content creator and website administrator must face.XSS attacks exploit vulnerabilities in websites, injecting malicious code into web pages. When other users visit the web page, the malicious code will execute on the user's browser, potentially stealing user information, hijacking sessions, or even tampering with web content, posing serious harm to the website and users.Fortunately, AnQiCMS has fully considered content security from the beginning of its design, providing us with multiple protective measures

2025-11-08