How to get and display detailed information of a single Tag label (Title, Description, Logo)?

Calendar 👁️ 74

In AnQi CMS, tags (Tag) are an important way to organize and associate content.Sometimes, we need not only to list tags, but also to be able to display detailed information about a single tag on an independent page or in a specific area, such as its title, description, or even a representative Logo.AnQi CMS provides a simple and efficient method to meet this requirement.

Understand the source of tag information

In the AnQi CMS backend, you can configure the details for each tag.Enter the "Content Management" under the "Document Tag" module, and you will find that each tag not only has a "Tag Name" but also can fill in the "Tag Description" (Description), "SEO Title", "Tag Keywords", and even upload a "Logo" image.This information maintained in the background is what we can obtain and display in the front-end template.

UsetagDetailRetrieve details of a single Tag

AnQi CMS provides special template tagstagDetailTo get detailed data for a single tag. This tag is designed to be very flexible, it can be on the tag detail page (such astag/detail.htmlortag/list.htmlIn such a template, the system will automatically identify the tag ID of the current page, and you can also obtain information about a specific tag on any other page by specifying the tag ID or its URL alias.

Basic usage

When you are on a tag detail page,tagDetailthe tag will automatically recognize the tag information on the current page. For example, if you visitexample.com/tag/seothentagDetailit will default to fetching all information for the tag 'SEO'.

{# 在标签详情页,系统会自动识别当前标签 #}
{% tagDetail tagInfo %}
    <h1>{{ tagInfo.Title }}</h1>
    {% if tagInfo.Logo %}
        <img src="{{ tagInfo.Logo }}" alt="{{ tagInfo.Title }} Logo" />
    {% endif %}
    <p>{{ tagInfo.Description }}</p>
    {# 如果标签有更长的内容(Content字段),可能需要使用|safe过滤器 #}
    {% if tagInfo.Content %}
        <div class="tag-content">{{ tagInfo.Content|safe }}</div>
    {% endif %}
{% endtagDetail %}

We used here{% tagDetail tagInfo %}Assign the details of the current tag to a variable namedtagInfo, and then call its properties through 等方式tagInfo.Title/tagInfo.Logo/tagInfo.Description. To retrieve the details of a specified Tag, use

.

If you want to display information about a specific tag on a non-tag detail page (such as the home page, article detail page, or a custom page), you can do so byidortokenTo specify the tag to be retrieved.

Suppose you want to retrieve the tag with ID.5The detailed information of the tag is as follows:

{# 获取ID为5的标签信息 #}
{% tagDetail specificTag with id="5" %}
    <h2>指定标签:{{ specificTag.Title }}</h2>
    {% if specificTag.Logo %}
        <img src="{{ specificTag.Logo }}" alt="{{ specificTag.Title }} Logo" class="small-tag-logo" />
    {% endif %}
    <p>简介:{{ specificTag.Description }}</p>
    <a href="{{ specificTag.Link }}">查看更多关于 {{ specificTag.Title }} 的内容</a>
{% endtagDetail %}

Similarly, you can also use the URL alias of the tag (tokenSpecify the label, which is usually the English name or pinyin of the label in pseudo-static configuration:

{# 获取URL别名为 "anqicms-tutorial" 的标签信息 #}
{% tagDetail tutorialTag with token="anqicms-tutorial" %}
    <h3>{{ tutorialTag.Title }}</h3>
    <p>这个标签的描述是:{{ tutorialTag.Description }}</p>
{% endtagDetail %}

Practice of displaying title, description, and Logo

Now, let's combine them to see an example of how to fully display a label's title, description, and Logo on a page:

<div class="tag-detail-card">
    {# 通过tagDetail标签获取当前页面(或指定ID/token)的标签详细信息 #}
    {% tagDetail currentTag %}
        <h2 class="card-title">{{ currentTag.Title }}</h2>

        {% if currentTag.Logo %}
            <div class="card-image">
                {# 展示Logo图片,并为其添加alt属性以优化SEO和可访问性 #}
                <img src="{{ currentTag.Logo }}" alt="{{ currentTag.Title }} 专属Logo" />
            </div>
        {% else %}
            {# 如果没有Logo,可以显示一个默认图标或提示 #}
            <div class="card-no-image">
                <i class="icon-tag"></i> <span>{{ currentTag.Title }}</span>
            </div>
        {% endif %}

        <div class="card-description">
            {# 展示标签的描述信息 #}
            <p>{{ currentTag.Description }}</p>
        </div>

        {# 添加一个链接,让用户可以点击查看该标签下所有的文章 #}
        <div class="card-link">
            <a href="{{ currentTag.Link }}">探索更多关于 {{ currentTag.Title }} 的内容 &raquo;</a>
        </div>
    {% endtagDetail %}
</div>

In this example, we first usetagDetailAssign the label information tocurrentTaga variable. Then, by accessingcurrentTag.Title/currentTag.LogoandcurrentTag.DescriptionDisplay the title, logo image, and description of the tag separately.We have added a conditional judgment to ensure that the image is displayed only when the logo exists, otherwise a backup solution is provided, which makes the page display more robust.

Summary

Of Security CMStagDetailTags provide website operators with powerful flexibility, allowing you to easily transform tags from simple content classification tools into richly displayed page elements. Whether it's creating unique tag landing pages for SEO or recommending related tags in articles,tagDetailCan help you present the required information in the most intuitive way.


Frequently Asked Questions (FAQ)

1. Why is the Logo image not displayed on my tag page?First, please check if you have uploaded a Logo image for this tag in the 'Content Management' -> 'Document Tag' section of the Anqi CMS backend.If not uploaded, the front-end will not display naturally. Next, please confirm whether your template code includes{% if currentTag.Logo %}This judgment logic, if the Logo field is empty,<img>label'ssrcthe property will also be empty, causing the image not to display.

2. Can I display the full content of a label instead of just a brief introduction, can I?Of course. In addition toDescription.tagDetaillabels also support getting the label'sContentfield. If you have filled in 'Label Content' in the background (usually supporting rich text or Markdown editing), you can use{{ currentTag.Content|safe }}to retrieve and display. Please note that due toContentThe field may contain HTML code, be sure to use|safefilter to prevent content from being escaped.

3. How to display the "Hot Tags" and their Logo in the sidebar, but not the tags of the current page?You need to combinetagListandtagDetailtags. First, use{% tagList hotTags with limit="5" order="views desc" %}Get the list of popular tags. Then, in the loophotTagseachitemin, and then use{% tagDetail singleHotTag with id=item.Id %}Get detailed information about each popular tag (including Logo). This allows multiple popular tags' Logo and title to be displayed on a non-tag detail page.

Related articles

How to display the document list under the specified Tag label and implement pagination?

In AnQi CMS, the Tag (tag) function is an important tool for organizing and associating content, enhancing user experience and website SEO performance.When your website content becomes richer, how to effectively display the document list under a specified Tag and provide clear pagination navigation is crucial for the discoverability of content and the continuous browsing of users.This article will give you a detailed explanation of how to easily implement this feature by using several key template tags in AnqiCMS.

2025-11-08

How to retrieve and display all single page lists in AnQi CMS?

Managing and displaying single pages in Anqi CMS is one of the basic functions for website content construction.A single page is usually used to create pages with relatively fixed structures and independent content, such as 'About Us', 'Contact Information', or 'Service Introduction', etc.If you wish to display a list of single pages in a specific area of the website, such as the footer navigation or sidebar, AnQi CMS provides a very intuitive and flexible way to achieve this.

2025-11-08

How to display the complete content and all fields of a single page?

In Anqi CMS, a single page is the basis for building static content pages such as 'About Us' and 'Contact Information'.Effectively displaying the complete content of these pages and all their fields is crucial for website customization and user experience.The Anqi CMS provides intuitive and powerful template tags, allowing you to easily display single-page data configured in the background on the website front-end. To display the complete content of a single page and all related fields, we mainly use the `pageDetail` core template tag.

2025-11-08

How to retrieve custom fields of a category on the category detail page?

When managing website content in AnQi CMS, we often need to make the category page not just a simple aggregation of document lists, but also able to carry more exclusive information to better guide users or display the characteristics of the category.It is particularly important to add and obtain custom fields for categorization at this time.By using these custom fields, you can make each category page unique, whether it's displaying a specific banner image, contact information, or the unique properties of the category.

2025-11-08

How to display the website name, Logo, filing number, and copyright information in Anqi CMS?

When operating a website, the website name, logo, filing number, and copyright information are core elements that constitute the brand image, establish user trust, and meet legal compliance requirements.For users of AnQiCMS, the system provides an intuitive and flexible way to manage and display this information, making your website not only rich in content but also professional and perfect in detail. ### One, centralized management: Configure these key information in the background One of the design philosophies of AnQi CMS is to make website management simple and efficient.

2025-11-08

How to retrieve and display the contact information, phone number, address, and email of the website?

In website operation, a clear and easily searchable contact method is a key factor in building user trust and promoting communication conversion.Whether you are seeking a partner for cooperation or a user in need of help, you can quickly find you through the contact information provided on the website.AnQiCMS provides flexible and convenient functions for managing and displaying contact information, allowing you to easily obtain and display various contact information such as contacts, phone numbers, addresses, and email addresses.

2025-11-08

How to set and display the TDK (Title, Description, Keywords) on the homepage of Anqi CMS?

In website operation, TDK (Title, Description, Keywords) play a crucial role, they are the first window for search engines to understand the content of the website, directly affecting the visibility and click-through rate of the website in search results.An optimally optimized TDK can not only improve the website's SEO performance but also accurately convey the core value of the website to potential visitors.AnQiCMS is a content management system that focuses on SEO optimization, providing users with a convenient and efficient way to set up and manage the TDK of the homepage.

2025-11-08

How to generate and display the breadcrumb navigation of the current page in Anqi CMS

When we browse websites, we often see a line at the top or bottom of the page indicating the current location path, such as “Home > Product Category > Electronic Products > Laptop”.This is what we commonly call 'breadcrumb navigation', which not only clearly informs us of our location but also makes it convenient for us to quickly return to the previous level page, greatly enhancing the website's user experience and navigation efficiency.In Anqi CMS, implementing and displaying breadcrumb navigation is a very easy thing to do.The system is built-in with special template tags that can intelligently adapt to the content structure of the current page

2025-11-08