How to list all Tag tags in the AnQiCMS template?

Calendar 👁️ 61

In Anqi CMS, using the template function to display all Tag tags on the website is an important operation that helps to improve content discoverability and website SEO.AnQiCMS as an efficient content management system provides an intuitive and flexible tag (Tag) management mechanism, allowing users to easily list these contents in website templates.

Learn about the Tag feature of AnQiCMS

In AnQiCMS, tags (Tag) can be considered as topics or keywords that connect different content.They do not follow the strict hierarchical structure of categories, but provide a more flexible way of classifying content, making it convenient for users to quickly find related articles or products based on their interests.In the background content management, whether it is articles, products, multiple tags can be added, these tags not only help users to search within the site, but also are an important basis for search engines to understand the relevance of website content.AnQiCMS provides a dedicated tag management interface, allowing users to view, add, edit, or delete tags, and these tags are not specific to any model or category. The same tag can be used to mark multiple types of content.

core: usingtagListDisplay all Tag tags

To list all the Tag tags in the AnQiCMS template, we mainly use a powerful template tag, that istagList. This tag is used to retrieve and display the tag list.

Generally speaking,tagListTags can be displayed based on the document ID of the current page to show tags related to that document. But if our goal is to display all tags on the website, not just the tags of a specific document, we need totagListSet a key parameter of the tag:itemId="0".

  • itemIdThe role of the parameter:When you setitemId="0"then,tagListThe tag will ignore the association with the specific document on the current page and instead query all existing Tag tags in the entire website database. This is the core setting to obtain the full site tag list.

exceptitemId="0"other than,tagListIt also provides some practical parameters to help us better control the display of tags:

  • limit(Display number)This parameter can limit how many tags you want to display. For example, if you want to display the top 10 tags in the sidebar, you can setlimit="10". It even supports offset mode, such aslimit="2,10"Will start displaying 10 labels from the second one.
  • letter(Index letter): If you want to filter tags in alphabetical order, for example, to display only tags that start with "A", you can setletter="A".
  • categoryId(Category ID): Although tags are usually not bound to categories, if you want to display only tags related to a specific or a few specific categories (for example, only display tags used in articles under the "News" category), you can usecategoryId="1"(If the category ID is 1) orcategoryId="1,2,3"(Multiple categories).
  • siteId(Site ID): For users running multiple sites, this parameter allows you to specify which site to retrieve tag data from. Generally, if you only operate one site, it is not necessary to set it.

tagListThe label data obtained will be returned in the form of a list (or array). Therefore, we need to use the template in theforLoop to traverse and display each tag. Each tag item will contain some available fields, such as:Id(Tag ID),Title(Tag Name),Link(Tag detail page link),Description(label description),FirstLetter(initial letters) et al.

Code examples and detailed explanation

Here is a simple template code example showing how to list all the Tag tags on the AnQiCMS template.

<div class="tag-cloud">
    <h3>热门标签</h3>
    <ul>
        {# 使用 tagList 标签获取所有标签,通过 itemId="0" 确保获取的是全站标签 #}
        {# limit="30" 可以限制显示的标签数量,这里设置为显示30个 #}
        {% tagList tags with itemId="0" limit="30" %}
            {% for item in tags %}
            <li>
                {# item.Link 是标签详情页的URL,item.Title 是标签的名称 #}
                <a href="{{item.Link}}" title="{{item.Title}}">
                    {{item.Title}}
                </a>
            </li>
            {% empty %}
            {# 如果没有任何标签,则显示此内容 #}
            <li>目前没有任何标签</li>
            {% endfor %}
        {% endtagList %}
    </ul>
</div>

Code analysis:

  1. <h3>热门标签</h3>This is a common HTML title used to mark the area of the tag list.
  2. {% tagList tags with itemId="0" limit="30" %}: This is the core part.
    • tagsWe will store the tag list namedtags.
    • itemId="0":Indicate that the system should retrieve all tags instead of tags specific to a particular document.
    • limit="30":We choose to display only the first 30 tags. You can adjust this number according to the page layout and requirements.
  3. {% for item in tags %}:TraversetagsEach variable label,itemrepresents the single label object being cycled through.
  4. <li><a href="{{item.Link}}" title="{{item.Title}}">{{item.Title}}</a></li>: For each label, we create a list item.<li>.
    • {{item.Link}}Output the detail page link of the current tag. Clicking it will take the user to a page containing all content of the tag.
    • {{item.Title}}:Output the current tag name, which is the text that we want the user to see.title="{{item.Title}}"It is to display the tag name when the mouse hovers over it, improving the user experience.
  5. {% empty %}This isforAn optional part of the loop, whentagsNo data is present in the list (i.e., the website has not set any tags) it will display<li>目前没有任何标签</li>.
  6. {% endfor %}and{% endtagList %}: respectively denoteforloop andtagListEnd of tag.

You can place this code in the website sidebar, footer, or any other location where you want to display all tags.

Display the Tag tag list on a dedicated page and support pagination.

AnQiCMS usually names the page template specifically used to display all tags astag/index.htmlIf you want to display all the Tag tags in a paginated form on this page, you can combinetagListoftype="page"Parameters andpaginationthe tag.

<div class="all-tags-page">
    <h1>所有网站标签</h1>
    <ul class="tag-list-paginated">
        {# 使用 tagList 标签获取所有标签并启用分页,这里每页显示20个标签 #}
        {% tagList tags with itemId="0" type="page" limit="20" %}
            {% for item in tags %}
            <li>
                <a href="{{item.Link}}">
                    <h5>{{item.Title}}</h5>
                    {% if item.Description %}
                        <p>{{item.Description}}</p>
                    {% endif %}
                </a>
            </li>
            {% empty %}
            <li>目前没有任何标签。</li>
            {% endfor %}
        {% endtagList %}
    </ul>

    {# 分页代码 #}
    <div class="pagination-controls">
        {% pagination pages with show="5" %}
            {# 显示首页链接 #}
            <a class="{% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
            {# 显示上一页链接 #}
            {% if pages.PrevPage %}
            <a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a>
            {% endif %}
            {# 显示中间页码 #}
            {% for item in pages.Pages %}
            <a class="{% if item.IsCurrent %}active{% endif %}" href="{{item.Link}}">{{item.Name}}</a>
            {% endfor %}
            {# 显示下一页链接 #}
            {% if pages.NextPage %}
            <a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a>
            {% endif %}
            {# 显示尾页链接 #}
            <a class="{% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
        {% endpagination %}
    </div>
</div>

This code will first usetagListTo get all the tags and prepare the pagination data, then usepaginationCreate pagination links for tags, convenient for users to browse all tag pages.

Summary

BytagListTags, AnQiCMS provides a flexible way to display all Tag tags on the website.It can be achieved by simple template code, whether it is to create a popular tag cloud or to build an independent page containing all tags.Make good use of tags, not only can it make the structure of the website content clearer, but also help users conveniently explore website information, and at the same time improve the performance of the website in search engines.

Frequently Asked Questions (FAQ)

  1. Question: How to only display Tag tags under a specific category in the tag list?Answer: If you want the tags listed to come only from certain categories within the website, you cantagListadd in thecategoryIdParameters. For example, to display all tags under categories with IDs 1 and 2, you can set it like this:{% tagList tags with itemId="0" categoryId="1,2" %}.

  2. Question: How to control the display quantity of Tag tags or paginate the tag list?Answer:tagListTags providedlimitParameters to control the display quantity, such aslimit="10"It will display 10 tags. If you need pagination, especially on specialized tag pages liketag/index.htmlyou can settagListlabel'stypethe parameter totype="page"and combiningpaginationTag to implement pagination navigation. For example:{% tagList tags with itemId="0" type="page" limit="20" %}Then match with{% pagination pages with show="5" %}...{% endpagination %}To generate pagination links.

  3. Ask: How is the detail page URL of the Tag label generated in AnQiCMS? Can I customize it?Answer: AnQiCMS will generate the detail page URL of the Tag label according to the pseudo-static rules set in the background. For example, the default format may be/tag/标签IDor/tag/标签别名. You can find the 'Static Rules' setting in the AnQiCMS backend function management and adjust the Tag as needed

Related articles

How to use the filtering feature of AnQiCMS to display a document list under specific conditions?

How to manage a large amount of content in AnQiCMS and allow users to quickly find the information they need is one of the key factors in content operation.Fortunately, AnQiCMS provides powerful filtering functions, allowing you to flexibly display document lists according to specific conditions, thereby greatly enhancing the website's user experience and content search efficiency. ### Clearly define your filtering requirements: Starting from the backend content model To make use of AnQiCMS's filtering feature, you first need to clarify the conditions through which you want users to search for content.

2025-11-08

How to dynamically display custom parameter fields of articles or products in AnQiCMS?

When building and operating a website, we often need to display more information than just the title and content, such as product models, colors, inventory, or the author, source, and publishing platform of the article.AnQiCMS knows the importance of personalized content display, and therefore provides a highly flexible custom parameter field function, making website content management and frontend display both powerful and convenient.Next, let's delve deeper together on how to make full use of this feature in AnQiCMS, making your website content dynamic.### First Step

2025-11-08

How to display related article recommendations on the AnQiCMS article detail page?

In website operation, the related article recommendation function on the article detail page can not only effectively improve the user's browsing depth within the site, reduce the bounce rate, but also guide users to discover more valuable content, indirectly improving the overall SEO performance of the website.AnQiCMS as a content management system that focuses on efficiency and scalability, provides flexible template tags, making it intuitive and convenient to implement this function. Let's discuss together how to elegantly implement related article recommendations on the article detail page of AnQiCMS.

2025-11-08

How to display the previous and next article links of the current article in AnQiCMS template?

In content operation, providing navigation to the previous and next articles for each article can not only significantly improve the user's reading experience, but also effectively increase the internal links of the website, which is of great benefit to search engine optimization (SEO).AnQi CMS with its flexible template system makes the implementation of this feature intuitive and efficient.By using a short template tag, you can easily integrate this practical navigation mechanism on the article detail page.

2025-11-08

How to display the description and link of a specific Tag label in AnQiCMS?

In Anqi CMS, a tag is a powerful content organization tool that not only helps you classify content more finely but also optimizes the website's SEO performance and improves the user's browsing experience.Sometimes, you may wish to display not only the name of the tag at a certain position on the website's frontend, but also its detailed description information, or even jump directly to the link related to the content of the tag.This is not a difficult task, Anqi CMS provides flexible template tags, allowing you to easily meet these needs.

2025-11-08

How to retrieve and display the list of documents under a specific Tag label in AnQiCMS?

In Anqi CMS, managing website content, the Tag tag is undoubtedly a very flexible and practical tool that helps us classify different categories and even different model content according to themes, greatly enriching the organization of content and the browsing experience of users.So when we want to display a list of all documents under a specific Tag on a dedicated page, Anqi CMS provides a very intuitive and powerful template tag to help us achieve this goal.### Understanding the role of Tag tags in Anqi CMS Before delving into the code

2025-11-08

How to display the comment list of a document in AnQiCMS and implement pagination?

In Anqi CMS, adding a comment list to the document page and implementing pagination is a key step to enhancing user interaction experience.This can not only let visitors participate in discussions and share opinions, but also brings more vitality to the website content.AnQi CMS provides intuitive and powerful template tags, allowing us to easily implement these features. ### Integrate the comment feature into your document detail page Comment lists and comment forms are typically integrated into the detail page of the document.

2025-11-08

How to generate and display the website's message form in AnQiCMS templates?

In website operation, an efficient and convenient feedback form is an important bridge for user interaction with the website.It not only collects user feedback, but also serves as the entry point for potential customers to obtain information.AnQiCMS as an enterprise-level content management system provides powerful and flexible functions in this aspect, allowing us to easily generate and manage comment forms in templates.

2025-11-08