How to manage and display document tags and associated document lists for `tagList` and `tagDataList` tags?

Calendar 👁️ 83

In content management, tags (Tag) are an important bridge connecting content, enhancing user experience, and optimizing search engine performance. Anqi CMS understands its importance and provides powerful tag management functions, and throughtagListandtagDataListThese core tags enable content operators to flexibly display and manage document tags and their associated content.

Tags: A tool for content classification and discovery.

In AnQi CMS, tags are not just simple keywords; they are a refined way of organizing content.You can add one or more tags to each article or product when publishing documents, and you can also create and manage tags separately under the 'Content Management' module in the background.Each tag can have an independent name, custom URL, SEO title, keywords, and description, which lays a solid foundation for the search engine optimization of the tag page.By tags, users can quickly find all content related to a specific topic, and search engines can also better understand the structure and thematic relevance of a website's content, thereby improving the visibility of the website.

tagList: Build a flexible tag display method.

When you want to display a series of popular tags, related tags, or all tags at any location on the website, such as in the sidebar, footer, or a dedicated tag index page (usuallytag/index.html),tagListLabels are your ideal choice.

Its basic purpose is to retrieve and cycle through the set of tags on the website.

While usingtagListYou can finely control the range of tags displayed by passing some parameters.

  • limit: Control the number of displayed tags. For example,limit="10"Only 10 tags will be displayed. If you want to start displaying 5 tags from the second tag, you can uselimit="2,5"such an offset mode.
  • itemId: If you want to display tags associated with a specific document, you can pass the document's ID. If set toitemId="0"It will retrieve all tags without automatically associating the documents of the current page.
  • categoryId: When you need to filter tags under a specific category, you can use this parameter, for example,categoryId="1,2,3"To display the tags of category ID 1, 2, 3.
  • letter: If you want to filter tags in alphabetical order, for example, to display only tags that start with 'A', you can useletter="A".
  • type="page": This parameter is very important, it allows you to implement pagination of the tag list on the tag index page(tag/index.html).

A simpletagListtag cloud example:

<div>
    <h4>热门标签</h4>
    {% tagList tags with limit="20" %}
    {% for item in tags %}
        <a href="{{item.Link}}" title="{{item.Description}}">{{item.Title}}</a>
    {% endfor %}
    {% endtagList %}
</div>

Display all tags with pagination on the tag index page:

When intag/index.htmltemplate usagetype="page"when using parameters, you can combinepaginationtags to implement pagination of the tag list:

<div>
    <h1>所有标签</h1>
    {% tagList tags with type="page" limit="30" %}
    <ul>
    {% for item in tags %}
        <li>
            <a href="{{item.Link}}">
                <h5>{{item.Title}}</h5>
                <div>{{item.Description}}</div>
            </a>
        </li>
    {% empty %}
        <li>目前没有标签可供显示。</li>
    {% endfor %}
    </ul>
    {% endtagList %}

    {# 标签列表分页代码 #}
    <div>
        {% pagination pages with show="5" %}
        {# 首页、上一页、中间页、下一页、尾页等导航元素 #}
        {% for pageItem in pages.Pages %}
            <a class="{% if pageItem.IsCurrent %}active{% endif %}" href="{{pageItem.Link}}">{{pageItem.Name}}</a>
        {% endfor %}
        {% endpagination %}
    </div>
</div>

BytagListYou can easily display tags in the corners of the website to guide users to explore the topics they are interested in.

tagDataList: Display related documents under the tags

When a user clicks on a tag, or you need to display all the documents under a tag (usuallytag/list.htmlortag_list.html),tagDataListthe tag comes into play.

Its core function is: to retrieve and display all documents associated with a specified tag ID.

tagDataListIt also provides a series of parameters to help you control the retrieval and display of documents:

  • tagIdThis istagDataListThe most critical parameter, you need to specify clearly which document under the label you want to obtain. On the label detail page, this ID is usually automatically obtained from the URL.
  • moduleId: If you only want to display documents under specific content models (such as article models, product models), you can use this parameter to filter.
  • order: Control the sorting method of documents, for exampleorder="id desc"(Sorted by ID in descending order, i.e., the most recent release) ororder="views desc"(Sorted by views in descending order, i.e., the most popular).
  • limit: Controls the number of documents displayed, also supports offset mode.
  • type="page": Allows you to implement pagination display of related documents on the tag document list page.
  • siteIdIn a multi-site environment, it is used to specify which site to retrieve data from.

An example of displaying a document list under a specific tag.

{# 在标签详情页,tagId 通常会自动从URL获取,或者您可以通过 tagDetail 标签获取 #}
{% tagDetail currentTag with name="Id" %} {# 获取当前页面的标签ID #}

<div>
    <h1>标签:{% tagDetail with name="Title" %}</h1>
    <p>{% tagDetail with name="Description" %}</p>

    {% tagDataList archives with tagId=currentTag type="page" limit="10" order="id desc" %}
    {% for item in archives %}
        <div class="document-item">
            <a href="{{item.Link}}">
                {% if item.Thumb %}<img src="{{item.Thumb}}" alt="{{item.Title}}">{% endif %}
                <h3>{{item.Title}}</h3>
                <p>{{item.Description}}</p>
                <span>发布时间:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>浏览量:{{item.Views}}</span>
            </a>
        </div>
    {% empty %}
        <p>该标签下暂无相关文档。</p>
    {% endfor %}
    {% endtagDataList %}

    {# 关联文档列表分页代码 #}
    <div>
        {% pagination pages with show="5" %}
        {# 分页导航元素 #}
        {% for pageItem in pages.Pages %}
            <a class="{% if pageItem.IsCurrent %}active{% endif %}" href="{{pageItem.Link}}">{{pageItem.Name}}</a>
        {% endfor %}
        {% endpagination %}
    </div>
</div>

BytagDataListYou can create dynamic and rich landing pages for each tag, allowing users to conveniently browse all documents under their interested topics, greatly enhancing the discoverability of content.

Integrate and Apply: Build an Efficient Tag Ecosystem

tagListandtagDataListThese tags usually work together to build an efficient tag content ecosystem. You can:

  1. On the homepage or sidebarUsetagListDisplay popular or recommended tags to attract user clicks.
  2. When a user clicks on a tag, it will jump to the detail page of that tag (tag/list.html), where you can make use oftagDetailLabel retrieves the detailed information of the current label (such as name, description, SEO data) as the page title and introduction, and then usestagDataListDynamically loads and displays all documents related to the label.

This combination not only strengthens the internal link structure of the website, is of great benefit to search engine optimization, but also provides users with a clear navigation path, making it easier for them to discover and consume relevant content

Related articles

How does the `pagination` tag handle the pagination display logic for article lists and product lists?

How to efficiently display a large number of articles or products in a content management system without sacrificing user experience, this is often a challenge faced by website operators.AnQiCMS (AnQiCMS) provides powerful template tag features, among which the `pagination` tag is a powerful tool to solve this problem, allowing flexible handling of pagination logic for article lists and product lists, making your website content well-organized.

2025-11-07

How `prevArchive` and `nextArchive` tags display the link and title of the previous/next document?

When browsing website content, users often hope to be able to easily jump from the current page to related or adjacent articles.This kind of previous/next navigation can not only significantly improve user experience, but also play an active role in SEO, guiding search engine spiders to more deeply crawl website content.

2025-11-07

How to generate breadcrumb navigation using the `breadcrumb` tag to enhance the user's understanding of the page hierarchy?

In complex website content structures, users sometimes feel lost, not knowing the position of the current page.At this time, an auxiliary navigation method called "Breadcrumb Navigation" is particularly important.It not only clearly displays the path from the home page to the current page, but also helps users quickly understand the hierarchical structure of the website, thereby improving the browsing experience.For websites built with AnQiCMS, the system-built `breadcrumb` tag is exactly the tool to generate this efficient navigation.

2025-11-07

How does the `contact` tag dynamically display website contact information (phone, address, email, etc.)?

AnQiCMS (AnQiCMS) provides a flexible and efficient way to manage various types of information on a website, where the dynamic display of website contact information can be easily realized through its built-in `contact` tag.This means you do not need to manually modify the code, and can manage phone numbers, addresses, email information centrally in the background, and have them automatically updated to various pages of the website. ### One, set the website contact information centrally in the background To dynamically display contact information, you first need to enter this information into the Anqi CMS backend.The operation path is very intuitive: log in to the background after

2025-11-07

How filters (such as `truncatechars`, `safe`, `floatformat`) handle and format the data to be displayed?

In AnQi CMS template design, filters play a crucial role, as they are like the 'beautician' and 'processor' of data, able to process and format the original data to be displayed in the template, making it more beautiful and more in line with requirements for visitors.Understand and make good use of these filters, which can make your website content more flexible and professional.

2025-11-07

How can AnQi CMS efficiently display and manage content from multiple sites on a single interface?

## AnQi CMS: The Secret to Mastering Multi-site Content on a Single Interface In the digital wave, many enterprises or individuals often have more than one website to meet different business or content publishing needs, such as brand official websites, product display pages, sub-sites, marketing activity pages, or independent sites for users in different regions or languages.However, managing and operating the content of multiple websites often becomes a huge challenge due to its complexity, repetitive workload, and the difficulty of resource integration.How to achieve the centralized display and management of these scattered contents on a unified platform

2025-11-07

How to utilize the flexible content model of Anqi CMS to create unique display methods for different types of content?

In today's increasingly important era of content marketing, the way a website presents its content directly affects user experience and the efficiency of information communication.A powerful and flexible content management system (CMS) can help us easily meet a variety of content display needs.AnQiCMS (AnQiCMS) leverages its excellent 'flexible content model' feature, providing endless possibilities for customized display of various content.This article will delve into how to cleverly utilize this core feature to create a unique presentation for your website content.Understanding AnQi CMS's flexible content model

2025-11-07

How does AnQi CMS support seamless switching and accurate display of multilingual content?

Today, with the increasing trend of globalization, companies and content creators have a growing demand for building multilingual websites.A CMS that can seamlessly switch and accurately display content, not only can it effectively expand the international market, but it can also significantly improve the user experience.AnQiCMS (AnQiCMS) provides a flexible and efficient solution in multilingual support, helping users easily cope with the challenges of global content operations.The Anqi CMS implements multilingual functionality based on its powerful multi-site management foundation.

2025-11-07