How to use the `tagDetail` tag to get the detailed information of a Tag, such as description and link?

Calendar 👁️ 66

In Anqi CMS, tags are an important tool for organizing content, improving SEO, and enhancing user experience.Sometimes, we need not only to list tags, but also to display detailed information about a specific tag on the page, such as its description, link, and even Logo.at this time,tagDetailThe label comes in handy, it helps us easily obtain this data.

tagDetailLabel overview

tagDetailThe primary function of the tag is to obtain detailed information of a single Tag tag. Whether it is on the detail page of the tag itself, the list page, or the document detail page where you want to display detailed data associated with a tag,tagDetailAll can provide flexible calling methods. Its basic usage form is as follows:

{% tagDetail 变量名称 with name="字段名称" id="标签ID" %}

Among them:

  • 变量名称Is an optional parameter, if you want to store the value obtained in a variable for subsequent repeated use, you can specify. If not specified,tagDetailwill output the result directly.
  • name="字段名称"It is crucial, it specifies the specific attribute of the Tag tag you want to obtain, such as title, link, description, etc.
  • id="标签ID"ortoken="标签URL别名"It is also an optional parameter. If the page you are currently on is the page of the Tag tag (for example, the tag detail page), thentagDetailIt will default to fetching the Tag information of the current page, no need to specifyidortoken. But if you want to fetchnot the current pagethe Tag information of a specific page, you can do so byid(Tag's unique numeric ID)ortokento specify the Tag's URL alias precisely.
  • siteIdThe parameter is used for multi-site scenarios, if you manage multiple sites and want to call data from other sites, you can specify the site ID through this parameter.In most cases, you do not need to worry about this parameter.

Let's take a look atnameThe parameter can retrieve which common tag information.

Detailed field analysis and application

tagDetailTag throughnameThe parameter can retrieve a series of fields related to Tag. Understanding these fields and how to call them gives you greater freedom in template design.

1. Tag ID (Id)

This is a unique numeric identifier for each tag.

{# 获取当前页面的Tag ID #}
<div>当前标签ID:{% tagDetail with name="Id" %}</div>

{# 获取指定ID为1的Tag ID #}
<div>指定标签ID:{% tagDetail with name="Id" id="1" %}</div>

{# 将Tag ID存储到变量中 #}
{% tagDetail myTagId with name="Id" %}
<div>我的标签ID是:{{ myTagId }}</div>

2. Tag Title (Title)

It is usually the display name of the tag and one of the most commonly used pieces of information.

{# 获取当前页面的Tag标题 #}
<h2>{% tagDetail with name="Title" %}</h2>

{# 获取指定ID为1的Tag标题 #}
<div>标签名称:{% tagDetail with name="Title" id="1" %}</div>

{# 将Tag标题存储到变量中 #}
{% tagDetail currentTagTitle with name="Title" %}
<h1>{{ currentTagTitle }}</h1>

3. Tag Link (Link)

This is the URL address of the tag detail page, convenient for users to click and jump to the list of all content related to the tag.

{# 获取当前页面的Tag链接 #}
<p>查看更多相关内容:<a href="{% tagDetail with name="Link" %}">点击这里</a></p>

{# 获取指定ID为1的Tag链接 #}
<a href="{% tagDetail with name="Link" id="1" %}">查看指定标签内容</a>

{# 将Tag链接存储到变量中 #}
{% tagDetail tagUrl with name="Link" %}
<a href="{{ tagUrl }}">进入标签页面</a>

4. Tag Description (Description)

Used to briefly introduce the purpose or content of the label, which is helpful for SEO and user understanding.

{# 获取当前页面的Tag描述 #}
<p>标签简介:{% tagDetail with name="Description" %}</p>

{# 获取指定ID为1的Tag描述 #}
<div>这是一个关于:{% tagDetail with name="Description" id="1" %}</div>

{# 将Tag描述存储到变量中 #}
{% tagDetail tagIntro with name="Description" %}
<p>{{ tagIntro }}</p>

5. Index letter (FirstLetter)

If the label name is English, this field will return the first letter (uppercase) for easy alphabetical classification display.

{# 获取当前页面的Tag首字母 #}
<span>标签首字母:{% tagDetail with name="FirstLetter" %}</span>

6. Label image (Logo)

If the background has set a thumbnail or Logo for the tag, you can get the image link through this field.

{# 获取当前页面的Tag Logo #}
<img src="{% tagDetail with name="Logo" %}" alt="{% tagDetail with name="Title" %}" />

{# 获取指定ID为1的Tag Logo #}
<img src="{% tagDetail with name="Logo" id="1" %}" alt="{% tagDetail with name="Title" id="1" %}" />

7. Tag content (Content)

This field can store more detailed label introduction or relevant information, usually in rich text (HTML) or Markdown format.

{# 获取当前页面的Tag内容,注意使用 |safe 过滤器防止HTML被转义 #}
<div class="tag-full-content">{% tagDetail with name="Content" render=true %|safe}</div>

{# 获取指定ID为1的Tag内容,并存储到变量中 #}
{% tagDetail specificTagContent with name="Content" id="1" render=true %}
<div class="specific-tag-details">{{ specificTagContent|safe }}</div>

Please note that whenContentIt is recommended to use|safeA filter to ensure that the content can be correctly parsed by the browser rather than displayed as plain text. If your backend has enabled the Markdown editor and the Content is in Markdown format, you will also need to addrender=trueParameter, let the system convert it to HTML before outputting.

Actual application example

Assuming you are building a tag list page for Anqi CMS, or in the sidebar of a document detail page, you need to display the detailed information of the current document's tags.

Scene one: Display the current tag's details on the tag detail page

Intemplate/你的模板目录/tag/detail.htmlortag/list.html(If configured as Tag detail page), you can call it like this:

<div class="tag-header">
    <h1>{% tagDetail with name="Title" %}</h1>
    <p class="tag-description">{% tagDetail with name="Description" %}</p>
    {% tagDetail tagLogo with name="Logo" %}
    {% if tagLogo %}
        <img src="{{ tagLogo }}" alt="{% tagDetail with name="Title" %}" class="tag-logo">
    {% endif %}
    <div class="tag-content">
        {% tagDetail tagFullContent with name="Content" render=true %}
        {{ tagFullContent|safe }}
    </div>
    <a href="{% tagDetail with name="Link" %}" class="btn btn-primary">查看所有关联内容</a>
</div>

This example shows how to directly retrieve and present the title, description, Logo, and detailed content of a tag on its dedicated page, while also providing a button linking back to itself.

Frequently Asked Questions (FAQ)

  1. Question:tagDetailThe label defaults to retrieving information for which Tag?Answer: If you do not provideidortokenparameter,tagDetailThe tag will intelligently try to retrieve the Tag information associated with the current page.For example, on the Tag detail page (the URL includes Tag ID or alias), it will automatically identify and display the data of the current Tag.In the document detail page, if the current document is associated with a Tag,tagDetail won'tThe system automatically retrieves the Tag information of the current document, you need totagListRetrieve the list of tags before calling it in a looptagDetailOr throughtagDetailofidSpecify the parameter.

  2. How can I display the details of a specific Tag associated with the current document on the document detail page?Firstly, you need to use in the document detail page,tagListUse the tag to get the list of all Tags associated with the current document. Then, you can iterate over this list and use each TagtagDetailtags, throughtagDetailofidparameter (passing initem.Id)to get the specific information of each Tag.

  3. Question:DescriptionandContentfields?Answer:DescriptionIt is usually used to store brief tag descriptions, with fewer words, mainly used for list display, SEO metadata(<meta name="description">)and other scenarios.ContentThe field can store more detailed and rich text and image content, possibly containing HTML or Markdown format, used as the main text on the tag detail page. When callingContentWhen a field contains HTML or Markdown, it must be used|safefilter, and Markdown content should be added withrender=trueParameter, to ensure that the content is parsed and displayed correctly.

Related articles

How to call the Tag list of the specified document in AnQiCMS template?

In AnQiCMS, tagging content (Tag) is an effective way to enhance content organization and user experience.These tags not only help search engines better understand the page theme, but also guide users to discover more related content.When you need to display the Tag list associated with a specific document in a template, AnQiCMS provides an intuitive and powerful `tagList` tag to make this operation very simple.

2025-11-08

How to add and manage multiple Tag tags in AnQiCMS?

In a content management system, effectively organizing and presenting information is the key to improving user experience and search engine performance.AnQiCMS provides a flexible Tag feature, which allows for more refined categorization of content, making it easier for users to quickly find content of interest and also provides strong support for website SEO optimization.This article will provide a detailed introduction on how to add and manage multiple Tag tags in AnQiCMS, and discuss its practical value in content operation.

2025-11-08

How can keyword library management in AnQiCMS's SEO tool help optimize website content?

In the increasingly fierce online competition, optimizing website content is the key to attracting and retaining users.For operators who want to stand out in search engines and continuously obtain high-quality traffic, a set of efficient SEO tools is undoubtedly a powerful assistant.AnQiCMS as an enterprise-level content management system provides many practical functions in SEO, among which keyword library management is the core tool for us to optimize website content and improve search engine performance. Imagine your website as a library, and keywords are like indexes guiding readers to the books you provide.

2025-11-08

What special characters are the `escape` and `escapejs` filters used to escape in the AnQiCMS template?

In AnQiCMS template development, to ensure the correct display of content and website security, we often use some built-in filters to handle special characters.Among them, the `escape` and `escapejs` filters are two very important tools, each serving different scenarios, and the types of special characters that need to be escaped are also different.

2025-11-08

How to get the associated document list based on Tag ID and how to paginate it for `tagDataList` tags?

In website content operation, effectively organizing and displaying related content is crucial for improving user experience and the SEO performance of the website.AnQiCMS (AnQiCMS) provides powerful tag features, where the `tagDataList` tag is the key tool to help us achieve this goal.It can flexibly retrieve all related document lists based on the specified tag ID, and easily achieve content pagination display by coordinating with other tags.

2025-11-08

What is the difference between the `{{variable}}` and `{% tag %}` syntax in AnQiCMS templates?

When using Anqicms to build a website, templates are the key to dynamic content display.We often see two special syntax structures in template files: `{{variable}}` and `{% tag %}`.Although they are all related to the display and processing of data, they play different roles and have different usage methods.Understanding the difference between them is the first step in efficiently using the Anqi CMS template.

2025-11-08

How to define and use custom variables in AnQiCMS templates, such as the `{% with %}` tag?

In the template design of AnQi CMS, we often encounter scenarios where we need to temporarily store or pass data.In order to make the template code clearer, easier to read, and more powerful, AnQi CMS provides the mechanism for defining and using custom variables, the most commonly used of which are the `{% with %}` tag and the `{% set %}` tag.They can help us handle data flexibly in templates, avoiding repeated calculations or passing complex objects.

2025-11-08

How does AnQiCMS's 'Full Site Content Replacement' feature efficiently handle content strategy adjustments?

Today, with the increasing refinement and diverse strategies of content operation, how to adjust website content efficiently and accurately is a challenge facing every website operator.When brand information is updated, external link adjustments, or SEO strategy iterations occur, manually modifying thousands of contents on the website one by one is not only time-consuming and labor-intensive, but also prone to errors.Fortunately, AnQiCMS provides an extremely powerful tool - the "Full Site Content Replacement" feature, which can help operators with amazing efficiency and accuracy to deal with various content updates and strategy adjustments, and become a "secret weapon" for content management strategy adjustments.###

2025-11-08