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

Calendar 👁️ 63

In AnQi CMS, the Tag (tag) function is an important tool for organizing and linking 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 explain in detail how to easily achieve this function in AnqiCMS by using several key template tags.

One, Understand the Tag label and its role in AnqiCMS

Tag label, as the name implies, is a way to classify website content with keywords or themes.Different from traditional classification (Category), a document can have multiple Tags at the same time, making the association between content more flexible and rich.For example, an article about "AnqiCMS template creation" can be tagged with "AnqiCMS", "template creation", "Go language", and so on.

On AnqiCMS backend, you can conveniently manage the document tags under the 'Content Management' module.Each tag can be set with an independent name, description, and SEO information, bringing a more detailed traffic entrance to the website.

Two, Core function tag analysis: Implementing Tag document list and pagination

We need to use several AnqiCMS core template tags to display the document list under a specified Tag on the front-end page and implement pagination.

  1. tagDetailLabel: Get the details of the current Tag

    • Function:Used to get the detailed data of the Tag displayed on the current page, such as the name, description, and link.
    • Usage scenario:Generally speaking,tag/list.htmlThis Tag list page is used, automatically obtaining the ID of the current Tag.
    • Common parameters:
      • name: Specify the field name to be retrieved, such asTitle(Label title),Description(Label description),Link(Tag link) and others.
      • idortokenIf you want to specify getting the details of a Tag on a non-Tag list page, you can use its ID or URL alias.
    • Example:
      
      {% tagDetail currentTag %} {# 将当前Tag的完整信息赋值给currentTag变量 #}
      <h1>标签:{{ currentTag.Title }}</h1>
      <p>描述:{{ currentTag.Description }}</p>
      
  2. tagDataListTags: Get the document list under the specified Tag.

    • Function:This is the core tag displayed under the Tag document, which can retrieve and list all related documents based on the specified Tag.
    • Usage scenario:On the Tag list page (such astag/list.htmlUsed to display all documents under the Tag.
    • Common parameters:
      • tagId: Specify the Tag ID to retrieve the document list in.tag/list.htmlPage, this parameter is usually omitted, the system will automatically read the current Tag's ID.
      • moduleIdIf your Tag is associated with different content models (such as articles, products), you can specify which model's document list to retrieve through this parameter.
      • type:Important!When you need pagination functionality, be sure to set it to"page". If only a fixed number is displayed, it is"list".
      • limit: How many documents are displayed per page (or per call).
      • order: Sorting rules, such as"id desc"(in reverse order by ID),"views desc"(Sorted by views in descending order).
    • Example:
      
      {% tagDataList archives with type="page" limit="10" %} {# 获取当前Tag下,每页10条的文档列表,并赋值给archives变量 #}
          {% for item in archives %}
              {# 文档内容展示 #}
          {% endfor %}
      {% endtagDataList %}
      
  3. paginationLabel: Generate pagination navigation

    • Function:IntagDataList(Or other list labels, such asarchiveList)type="page"The mode,paginationLabels can automatically generate a complete pagination navigation link based on the total number of documents on the current page and the number of documents displayed per page.
    • Usage scenario:FollowingtagDataList(orarchiveListAfter the tag, it is used to generate the pagination HTML.
    • Common parameters:
      • showIt controls how many page number links are displayed in the pagination navigation (excluding the home page, previous page, next page, etc.).
    • Example:
      
      {% pagination pages with show="5" %}
          {# ... 分页链接的HTML结构 ... #}
      {% endpagination %}
      

Chapter 3: Practical: Build the document list page under Tag tag

According to the AnqiCMS template conventions, the template file for displaying the document list under a specific Tag label is usually located in the current template directory you are using.tag/list.htmlIf you don't have this file, please create it.

The following is a completetag/list.htmlTemplate code example, it will display the name and description of the current Tag, as well as the document list under the Tag, and provide pagination functionality:

`twig {# Inherit the base template, such as base.html #} {% extends 'base.html' %}

{# Set page TDK information, AnqiCMS will automatically fill in the Tag's TDK #} {% block title %}{% tdk with name=“Title” siteName=true %}{% endblock %} {% block keywords %}{% tdk with name=“Keywords” %}{% endblock %} {% block description %}{% tdk with name=“Description” %}{% endblock %}

{% block content %}

{# 面包屑导航 #}
{% breadcrumb crumbs with index="首页" %}
<ol class="breadcrumb">
    {% for item in crumbs %}
    <li{% if item.IsCurrent %} class="active"{% endif %}>
        {% if item.IsCurrent %}{{item.Name}}{% else %}<a href="{{item.Link}}">{{item.Name}}</a>{% endif %}
    </li>
    {% endfor %}
</ol>
{% endbreadcrumb %}

{# 获取当前Tag的详细信息 #}
{% tagDetail tag %}
<h1 class="page-title">{{ tag.Title }}</h1>
{% if tag.Description %}
<p class="tag-description">{{ tag.Description }}</p>
{% endif %}

{# 获取该Tag下的文档列表,并支持分页 #}
{% tagDataList archives with type="page" limit="10" order="id desc" %}
<div class="document-list">
    {% for item in archives

Related articles

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 implement multi-level category nesting display in Anqi CMS?

The organization of website content is crucial for user experience and information retrieval efficiency.A clear and logical classification system can help visitors quickly find the information they need, and also lay a good foundation for the website's SEO.In Anqi CMS, implementing nested display of multi-level categories is the key to building this efficient content architecture.It is not just to list categories simply, but also to modularize and organize the content through hierarchical relationships, whether it is product display, article archive, or service introduction, it can be presented to users in a more intuitive way.

2025-11-08

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

In AnQi CMS, tags (Tag) are an important way to organize and associate content.Sometimes, we need not only list the tags but also hope to display detailed information about a single tag on an independent page or in a specific area, such as its title, description, and even a representative logo.The AnQi CMS provides a concise and efficient method to meet this requirement. ### Understanding Tag Information Source In the Anqi CMS backend, you can configure the details for each tag.

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