How to retrieve and display detailed descriptions and associated documents for a specific tag?

Calendar 👁️ 62

In content management, tags are a powerful and flexible tool that helps us organize website content more finely, enhance user experience, and optimize search engine rankings.AnQiCMS knows this well and provides intuitive and feature-rich template tags that allow you to easily obtain and display the detailed description of a specific tag and its associated documents.

This article will deeply explore how to use these tags in the AnQiCMS template to make your website content more relevant and discoverable.

Understand the tags in AnQiCMS

In the design philosophy of AnQiCMS, tags are a form of horizontal association and complementary classification of content.Different from the traditional classification (Category) that usually uses a hierarchical structure, tags are more focused on keyword aggregation and can connect related content across different categories and even different content models.For example, an article can belong to the "news" category and be tagged with "AnQiCMS", "update", "tutorial", and other tags.

In the AnQiCMS backend management interface, you can add, edit, and manage these tags uniformly under 'Content Management' -> 'Document Tags'.Each tag can have an independent name, index letter, detailed description, even a custom URL alias and SEO information, all of which lay the foundation for the flexible display of front-end content.

Get the detailed description of a specific tag

When we want to display the detailed information of a tag itself on a website page, for example, on the tag detail page (usually corresponding totag/detail.htmlortag_detail.htmltemplate) AnQiCMS providestagDetailThe tag can help us accurately obtain various properties of a tag.

UsetagDetailwhen using tags, you can go throughid(label ID) ortokenSpecify the URL alias of the tag to retrieve information for the desired tag. If you are currently on the details page of a tag and have not specifiedidortoken,tagDetailIt will intelligently obtain the tag information on the current page.

The tag fields you can obtain include:

  • Id: The unique identifier ID of the tag.
  • Title: The display name of the tag, such as 'AnQiCMS Tutorial'.
  • Link: The access link of the tag.
  • Description: Detailed description of the tag, often used for SEO or providing more background information on the page.
  • Content: If rich text content is filled in for the tag on the backend, it can be obtained through this field.
  • FirstLetterThe first letter of the tag name (used for indexing).
  • LogoThe thumbnail or icon of the tag.

The following is an example code snippet to retrieve the title and description of the tag:

{# 假设我们正在一个标签详情页,或者我们知道标签ID是1 #}

{# 获取标签标题 #}
<h1>{% tagDetail with name="Title" %}</h1>

{# 获取标签描述,如果描述包含HTML,需要使用 |safe 过滤器 #}
<div>
    {% tagDetail tagDescription with name="Description" %}
    {{ tagDescription|safe }}
</div>

{# 如果标签有Logo图片,可以这样显示 #}
{% tagDetail tagLogo with name="Logo" %}
{% if tagLogo %}
    <img src="{{ tagLogo }}" alt="{% tagDetail with name='Title' %}" />
{% endif %}

{# 如果标签有富文本内容,同样需要 |safe 过滤器 #}
{% tagDetail tagContent with name="Content" %}
{% if tagContent %}
    <section>{{ tagContent|safe }}</section>
{% endif %}

Please note that when the field content may contain HTML tags (such as Description or Content), it is imperative to use|safeA filter to ensure that this HTML content can be correctly parsed and displayed by the browser, rather than being output as plain text.

Get the document list associated with the tag

After displaying the detailed information of the tag, users usually expect to see all related documents (articles, products, etc.) under the tag. AnQiCMS provides this fortagDataListTags, it can retrieve all related content based on the specified tags.

tagDataListThe way of using tags andarchiveListSimilar, it will return a list of documents (or products). Its main parameters include:

  • tagId: Specify the tag under which the document should be retrieved. If the current page is the detail page of a tag, this parameter is usually omitted, and the system will default to retrieving the current tag ID.
  • moduleIdIf your website has multiple content models (such as articles, products), you can use this parameter to specify only the documents under a specific model, for examplemoduleId="1"Get articles,moduleId="2"Get products.
  • limit: Controls the number of documents returned, for examplelimit="10"Will return up to 10 documents.
  • type: Specify the type of list,"list"Used for lists without pagination,"page"Used for lists that support pagination (requires to be used withpaginationLabel配合使用)。

tagDataListIt will return an array containing document objects, you can useforLoop through these documents and extract information such as title, link, description, thumbnail, and publication time.

Here is an example of retrieving a list of documents associated with the current tag.

`twig {# Retrieve the document list associated with the current tag, display 10 per page, and support pagination #} {% tagDataList archives with type="page" limit="10" %}

{% if archives %}
    <ul class="related-docs">
        {% for item in archives %}
        <li>
            <a href="{{ item.Link }}">
                <h3>{{ item.Title }}</h3>
                {% if item.Thumb %}
                    <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="doc-thumb" />
                {% endif %}
                <p>{{ item.Description|truncatechars:100 }}</p>
                <span class="doc-info">
                    发布时间:{{ stampToDate(item.CreatedTime, "2006-01-02") }} | 
                    浏览量:{{ item.Views }}
                </span>
            </a>
        </li>
        {% endfor %}
    </ul>

    {# 关联分页标签,用于生成分页导航 #}
    {% pagination pages with show="5" %}
        <nav class="pagination-nav">
            <a href="{{ pages.FirstPage.Link }}" class="page-link {% if pages.FirstPage.IsCurrent %}active{% endif %}">首页</a>
            {% if pages.PrevPage %}<a href="{{ pages.PrevPage.Link }}" class="page-link">上一页</a>{% endif %}
            {% for p in pages.Pages %}
                <a

Related articles

How to display a list of commonly used tags on a website or tags of specific documents?

In AnQiCMS, efficiently manage and display website tags, which can not only help users find the content they are interested in faster, but also effectively improve the SEO performance of the website.Tags as a flexible content classification method can associate content spanning different categories and even different models, forming a content matrix.Below, we will start from several common application scenarios and explain in detail how to display the list of commonly used tags on your website, as well as how to display associated tags for specific documents.### The Importance of Tags Tags are a powerful content management tool in AnQiCMS

2025-11-08

How to implement filtering conditions based on document parameters and display the filtering results?

In AnQiCMS (AnQiCMS), using document parameters to build flexible filtering conditions and display the filtering results is a key factor in improving website user experience and content management efficiency.This not only helps users find the information they need faster, but also makes the website's content structure clearer.This article will introduce you to how to implement this feature in AnQi CMS, from the initial parameter definition to the final filtering and display, helping you easily master content management.## Make content smarter: How to cleverly use document parameters to implement filtering function in Anqi CMS As the content of the website continues to enrich

2025-11-08

How to display custom parameters on an article or product detail page?

In website operation, adding personalized information to articles or product detail pages is the key to improving content professionalism and user experience.AnQiCMS (AnQiCMS) fully understands this need and provides powerful customizable parameter functions, allowing us to flexibly add and display the required information according to different content types. Imagine you publish a technical article, in addition to the title and content, you also want to display unique attributes such as "author", "publish date", "technology stack", and so on; Or maybe, you are selling a product, in addition to the usual name, price, and description, you also want to highlight the "color"

2025-11-08

How to display a list of related articles below the article detail page?

In website operation, the list of "related articles" at the bottom of the article detail page is an important function to enhance user experience, increase page views (PV), and prolong the time users stay on the site.It can guide users to discover more interesting content, thereby enhancing the overall stickiness of the website, and also has a positive effect on search engine optimization (SEO).To implement this feature in AnQi CMS, it benefits from its flexible template system and powerful tag functions, making the entire process intuitive and efficient.### One, understand the call mechanism of "related articles" The template tags of AnQi CMS are the core of realizing various functions

2025-11-08

How to display the user comment list below the article page?

In website operation, user comments are an important aspect for enhancing content interaction, strengthening community atmosphere, and optimizing search engine rankings (SEO).AnQiCMS provides a flexible and powerful template tag system, making it easy and convenient to integrate a user comment list and comment form at the bottom of the article page.This article will provide a detailed introduction on how to elegantly display user comments on the article detail page of AnQi CMS, and also provide a function for users to submit comments.

2025-11-08

How to integrate and display a friend link list on a website?

In website operation, friendship links play an indispensable role. They are not only the bridges to establish contact with other websites but also effective ways to improve website authority, obtain external traffic, and enhance user experience.AnQiCMS as an efficient and flexible content management system provides an intuitive and convenient solution for the integration and display of friend links. ### First Part: Admin Friend Links One of the design philosophies of AnQiCMS is to make website operation more efficient, and the management of friend links is naturally integrated very well.

2025-11-08

How to correctly display pagination navigation for articles or category lists?

When managing website content, whether it is an article list, product display, or other category pages, a clear and effective pagination navigation is crucial for improving user experience and search engine optimization.AnQiCMS (AnQiCMS) provides powerful template tag features, allowing us to easily add correct pagination navigation to the list page.This article will introduce how to implement this feature in AnQi CMS.

2025-11-08

How to use `if` and `for` tags to flexibly control content display logic?

## Unlock the mysteries of AnQi CMS content display: the flexible use of `if` and `for` tags AnQi CMS is committed to providing users with an efficient and customizable content management experience.In website content operation, we often need to display different information based on different conditions, or display a series of contents in bulk.

2025-11-08