How to display the AnQiCMS tag list by page number (limit)?

Calendar 👁️ 66

As an experienced website operations expert, I know that how to efficiently and flexibly display content in a content management system is the key to success in operations.AnQiCMS with its concise and efficient architecture and powerful template tag system, provides us with great convenience.Today, let's delve deeply into a common yet crucial feature: how to implement pagination of the tag list by the number of calls (limit) in AnQiCMS.

Tags (Tag) are an important means of content organization, they not only help users quickly find related content, but are also an indispensable part of SEO strategy.As the content of the website becomes richer, the number of tags may also increase.If all labels are displayed in a flat and straightforward manner, it not only affects the page loading speed, but also reduces the user experience.Therefore, it is particularly important to manage the tag list with pagination and load on demand.

Understand the tag mechanism of AnQiCMS:tagListwithtagDataList

In AnQiCMS, we mainly use two template tags to handle label-related data:

  1. tagListTagThis tag is mainly used to getthe tag list itself on the website. It can be used to display all popular tags, the latest tags, or tags associated with a specific document. It returns an array containing all tag information.
  2. tagDataListTag: As the name implies, this tag is used to obtainthe document list under a specific tag. When you click on a tag and enter the tag detail page, it is usually used totagDataListDisplay all articles or products associated with this tag. It returns an array of document (Archive) information related to the specific tag.

Understanding the difference between these two is the key to implementing tag list pagination.

The core of implementing tag list pagination:limitThe parameter withpaginationTag

To implement pagination display of the tag list in AnQiCMS, we mainly rely on two core parameters and a key tag:

  • limitParameterIt defines the number of data to be displayed per page or each call. For example,limit="10"means 10 data are displayed per page.
  • type="page"ParameterIt is the switch to turn on pagination. When you turntypeis set to"page"When, AnQiCMS knows that you need to perform pagination, and it will generate the corresponding pagination information for the list.
  • paginationTagThis tag is designed for pagination in AnQiCMS, it can automatically generate 'First page', 'Previous page', 'Next page', and specific page number links according to the total number of data in the list and the number of items displayed per page.

Next, we will explain in detail how to use these functions in two scenarios.

Scenario one:tagListTag pagination display

Assuming you want to display all the tags on a special "tag cloud" or "hot tags" page (usuallytag/index.htmltemplate file) and display them in pages instead of loading all at once.

1. UsetagListLabel to get the paginated label data:

First, in your template file (for exampletag/index.htmlUse it intagListLabel to get label data and specifytype="page"andlimitParameter.

{# 在 tag/index.html 模板中,用于分页显示网站所有标签 #}
{% tagList tags with type="page" limit="20" %}
    <div class="tag-list-container">
        {% for item in tags %}
        <a href="{{ item.Link }}" title="{{ item.Title }} ({{ item.ArchiveCount }}篇文章)" class="tag-item">
            {{ item.Title }}
        </a>
        {% empty %}
        <p>抱歉,目前没有可显示的标签。</p>
        {% endfor %}
    </div>
{% endtagList %}

In the above code:

  • We defined a namedtagsThe variable to receivetagListThe returned label data.
  • type="page"Explicitly tell the system that pagination is needed.
  • limit="20"Set 20 tags to be displayed per page.
  • {% for item in tags %}Loop through the obtained tag data.
  • item.Linkanditem.TitleUsed to display tag links and names.
  • item.ArchiveCountIf the document supports this field, it can display how many articles are under the tag, increasing the reference value of the tag.

Important reminder:According to the AnQiCMS document conventions,tagListTags are only available whentag/index.htmlIn the template, itstype="page"parameters must be effective and generate pagination. In other templates, it may not generate pagination effects or only returntype="page"a limited non-pagination list.limit.

2. CombinedpaginationTag rendering pagination navigation:

After obtaining the pagination data, the next step is to display the page numbers that the user can click to jump. This ispaginationthe application of tags.

{# 紧接着上面的 tagList 标签之后,用于显示分页导航 #}
<div class="pagination-container">
    {% pagination pages with show="5" %}
        <ul class="pagination">
            {# 首页链接 #}
            {% if pages.FirstPage %}
            <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}">
                <a class="page-link" href="{{ pages.FirstPage.Link }}">{{ pages.FirstPage.Name }}</a>
            </li>
            {% endif %}

            {# 上一页链接 #}
            {% if pages.PrevPage %}
            <li class="page-item">
                <a class="page-link" href="{{ pages.PrevPage.Link }}">{{ pages.PrevPage.Name }}</a>
            </li>
            {% endif %}

            {# 中间页码 #}
            {% for pageItem in pages.Pages %}
            <li class="page-item {% if pageItem.IsCurrent %}active{% endif %}">
                <a class="page-link" href="{{ pageItem.Link }}">{{ pageItem.Name }}</a>
            </li>
            {% endfor %}

            {# 下一页链接 #}
            {% if pages.NextPage %}
            <li class="page-item">
                <a class="page-link" href="{{ pages.NextPage.Link }}">{{ pages.NextPage.Name }}</a>
            </li>
            {% endif %}

            {# 尾页链接 #}
            {% if pages.LastPage %}
            <li class="page-item {% if pages.LastPage.IsCurrent %}active{% endif %}">
                <a class="page-link" href="{{ pages.LastPage.Link }}">{{ pages.LastPage.Name }}</a>
            </li>
            {% endif %}
        </ul>
        <div class="page-info">
            总计 {{ pages.TotalItems }} 个标签,共 {{ pages.TotalPages }} 页,当前第 {{ pages.CurrentPage }} 页。
        </div>
    {% endpagination %}
</div>

Here:

  • We definedpagesVariables to receivepaginationThe pagination object generated by the tag.
  • show="5"Controlled in

Related articles

How to get the list of Tag tags for a specified document?

As an experienced website operations expert, I am well aware of the importance of tags (Tag) in content management and website optimization.They can not only help users quickly locate the content they are interested in, but also provide clearer website structure information for search engines, thereby improving SEO effectiveness.In such a powerful content management system as AnQiCMS, it is a core skill for every operator and developer to master the flexibility of obtaining and displaying the Tag tag list of a specified document.

2025-11-07

How to display the list of all document tags in AnQiCMS template?

As an experienced website operations expert, I know that the development of content management system templates is the key to website operation efficiency and content display effect.AnQiCMS (AnQiCMS) provides us with great convenience with its efficient and flexible features based on the Go language.Today, let's delve deeply into a very practical requirement in content operation: how to elegantly display the tag list of all documents in the AnQiCMS template.Tags play a crucial role in modern website content management.

2025-11-07

How to display WeChat QR code or social media account links in AnQiCMS templates

In the era where content is king, businesses and self-media operators are all aware of the importance of building an effective connection with users.And social media, especially WeChat, is undoubtedly an efficient channel for connecting users, sharing information, and providing services.AnQiCMS (AnQiCMS) is a system designed for efficient content management, naturally understanding this well, and providing strong and convenient support for users to flexibly display WeChat QR codes or links to various social media accounts in website templates.

2025-11-07

How to uniformly display contact information, phone numbers, email addresses, and other contact details in the footer of a website?

As an experienced website operations expert, I know that the website footer, although seemingly unimportant, is a crucial area for users to find key information and establish trust.Unified and clearly displaying contact information not only enhances user experience but is also an important embodiment of website professionalism and service capabilities.For enterprises and content operation teams using AnQiCMS, it is easy to achieve this thanks to its flexible template mechanism and convenient backend management features.

2025-11-07

How to get the Tag list starting with a specific letter in AnQiCMS?

As an experienced website operation expert, I am happy to discuss the subtle aspects of AnQiCMS (AnQiCMS) in content operation with you.AnQiCMS with its efficient and customizable features, provides a powerful toolkit for content creators and operators.Today, let's delve into a specific and practical scenario: how to elegantly obtain a list of Tags starting with a specific letter in AnQiCMS, thereby achieving more refined content organization and display.

2025-11-07

How to display the details of a single Tag in AnQiCMS template?

As an experienced website operations expert, I am happy to give you a detailed explanation of how to flexibly and efficiently display the detailed information of a single Tag in AnQiCMS.AnQiCMS with its concise and efficient architecture provides powerful template customization capabilities for content operators.To deeply understand the presentation of individual Tag information, we first need to start with its template mechanism and core tags.How to display the details of a single Tag in AnQiCMS template?

2025-11-07

How to get the name, link, and description of a specified Tag?

As an experienced website operations expert, I know that effectively utilizing tags (Tags) in a content management system is crucial for the SEO, content organization, and user experience of the website.AnQiCMS (AnQiCMS) boasts powerful template functions and a flexible tag system, allowing you to easily display and manage these valuable information on the front end of the website.Today, let's delve deeply into how to accurately obtain the name, link, and description of a specified Tag in AnQiCMS, thereby providing stronger support for your content operation.In AnQiCMS

2025-11-07

How to retrieve the associated document list according to TagID in AnQiCMS?

## Unlock Content Association: How to Efficiently Retrieve Related Document Lists in AnQiCMS Tags are an important tool for connecting content, improving user experience, and optimizing search engine visibility in content management systems.AnQiCMS, as an enterprise-level content management system developed based on the Go language, is well-versed in this field and provides flexible and powerful tag features.For website operators, how to accurately obtain and display the document list associated with a specific tag ID is a key link in the realization of refined content operation.

2025-11-07