How to call and display the list of all website tags (Tag) in AnQiCMS template?

Calendar 👁️ 72

As an experienced website operations expert, I am happy to give you a detailed explanation of how to efficiently and elegantly call and display the Tag list of all websites in the AnQi CMS template.AnQi CMS with its powerful content management capabilities and flexible template mechanism makes this operation intuitive and practical.


Unveiling AnQi CMS: How to call and display all website tag lists in the template

In the era of modern content marketing and SEO optimization, website tags (Tags) play a crucial role.They can not only help users find relevant content quickly and improve the in-site navigation experience, but are also key elements for search engines to understand the theme of the website content.AnQi CMS fully understands its importance and provides a complete tag management function.How can you effectively display these valuable tags in your website template?

Overview of core features: Tag management mechanism of AnQi CMS

On the Anqi CMS backend, you will find the powerful 'Document Tag' management module.Here, you can create, edit, delete various tags, and associate them with your articles, products, and other content.Each tag can have an independent name, index letter, custom URL, and even a dedicated SEO title and description, which lays a solid foundation for subsequent template calls and SEO optimization.

The tag design of AnQi CMS is very flexible, a tag can be associated with documents of different content models at the same time, thus realizing cross-model content aggregation.In the front-end template, we are able to intelligently obtain and render these label data through built-in template tags.

Call and display all tag list templates magic

To call and display all website tag lists in the AnqiCMS template, we need to usetagListThis is the core template tag. This tag is designed to be very flexible, meeting various calling needs from hot tags to the entire site tags.

Generally, you would want to place it at a specific location on the website, such as the homepage sidebar, footer navigation area, or a dedicated "tag cloud" page (usually corresponding to a template filetag/index.html) to display these tags.

Here is the basic structure of the code to call the list of all tags:

<div class="tag-cloud">
    <h2>网站所有标签</h2>
    <ul class="tag-list">
        {% tagList allTags with itemId="0" %} {# 明确指定获取全站所有标签 #}
            {% for tag in allTags %}
                <li class="tag-item">
                    <a href="{{ tag.Link }}" title="查看更多关于 {{ tag.Title }} 的内容">{{ tag.Title }}</a>
                </li>
            {% else %}
                <li class="no-tags-message">抱歉,目前还没有任何网站标签。请在后台添加。</li>
            {% endfor %}
        {% endtagList %}
    </ul>
</div>

Let's parse the logic of this code step by step:

  1. {% tagList allTags with itemId="0" %}: This is the core.

    • tagListIs a template tag provided by AnQi CMS specifically for obtaining the tag list.
    • allTagsIt is a variable name specified for the label list data obtained. You can customize it as you like, for examplemyTagsorwebsiteTags.
    • with itemId="0"It is the key parameter here. When you need to obtainAll labels on the sitewhen, explicitlyitemIdis set to0This will tell the system to ignore any content ID associations on the current page and directly pull all published tag data.If you are on a non-content detail page (such as the homepage) and do not specifyitemIdthe system may also default to returning all tags, but for the clarity and robustness of the code, it is explicitly specifieditemId="0"is a good habit.
  2. {% for tag in allTags %}: The tag list data will be returned as an array object toallTagsthe variable, so we need to usefora loop to iterate through it. In each iteration,tagthe variable will represent an independent tag object.

  3. <li class="tag-item"><a href="{{ tag.Link }}" title="查看更多关于 {{ tag.Title }} 的内容">{{ tag.Title }}</a></li>In the loop body, you can access the properties of each tag object and display them.

    • {{ tag.Link }}This is the URL link of the label, clicking on it will usually jump to the content list page under the label.
    • {{ tag.Title }}This is the display name of the tag.
    • exceptLinkandTitleYou can also access other useful fields, such astag.Id(Label ID),tag.Description(Label description),tag.FirstLetter(Label initial letter) etc., apply flexibly according to your design requirements.
  4. {% else %}This isforAn elegant extension of the loop. IfallTagsThe list is empty (i.e., the website currently has no tags), thenelseThe content will be rendered out, giving the user a friendly prompt.

Deep customization: More possibilities for tag lists

In addition to displaying all tags,tagListTags also provide rich parameters, allowing you to have more fine-grained control:

  • Limit the Display Quantity: If you only want to display the top 10 popular tags in the sidebar, you can addlimit="10"parameters:{% tagList hotTags with itemId="0" limit="10" %}.

  • Sort by alphabet: Would you like to create a label navigation sorted alphabetically? You can useletter="A"orletter="B"set parameters such as.

  • Label list pagination: If your website has a large number of tags, you can put them on a dedicated tag page (such astag/index.htmlOn it, you can combinetype="page"Parameters andpaginationtags to implement pagination display, optimize loading speed and user experience.

    {# 示例:在tag/index.html中分页显示所有标签 #}
    {% tagList allTagsPage with type="page" limit="20" %}
        {# 遍历并显示标签的代码与上述类似 #}
        {% for tag in allTagsPage %}
            <li class="tag-item">
                <a href="{{ tag.Link }}" title="{{ tag.Title }}">{{ tag.Title }}</a>
            </li>
        {% endfor %}
    {% endtagList %}
    
    {# 别忘了加上分页导航 #}
    {% pagination pages with show="5" %}
        {# 分页链接的渲染代码 #}
        {# ... 这里省略具体的页面链接渲染代码,可参考文档中的pagination标签用法 #}
    {% endpagination %}
    

When the user clicks on a tag, it will jump to the detail page of that tag (usually corresponding to a template file)tag/list.html), at this time you can usetagDataListTag to retrieve the list of all associated documents under this tag, further improving content aggregation.

Considerations and suggestions in practice.

  • Template File Location: Place the above code in the template file where you want to display the tag list. If it is a site-wide feature, you can consider placing it inpartial/the directory under a common template file (such assidebar.htmlorfooter.html),then use{% include "partial/sidebar.html" %}The way to introduce it into the main template.
  • Style beautificationThe beauty of the tag list directly affects user experience. By usingdiv.tag-cloud/ul.tag-list/li.tag-item

Related articles

What core information can be viewed in the Tag management interface of AnQiCMS?

The AnQiCMS Tag management interface, as your powerful assistant for content operation, is far more than just a simple keyword list.It is a meticulously designed hub that provides you with a series of core information, which is crucial for optimizing your website content structure, improving search engine visibility, and enhancing the user browsing experience.As an experienced website operations expert, I will take you deep into the AnQiCMS tag management interface to view and manage all core information, helping you to master content marketing strategies more efficiently.

2025-11-07

Where will the 'Description Content' field of the AnQiCMS document tag be displayed?

In the daily operation of Anqi CMS, we often use document tags (Tag) to classify and index content, which not only helps users quickly find the content they are interested in, but is also an indispensable part of search engine optimization (SEO).After we have carefully filled in the 'Description' field for each tag, a natural question arises: where will this valuable description information be displayed on the website?Today, let us dive into the secrets of the AnQiCMS document tag "description content" with this senior operation expert.

2025-11-07

How to add multiple Tag tags to AnQiCMS documents to enhance content relevance?

As an experienced website operations expert, I fully understand the importance of content relevance for the SEO performance and user experience of a website.In a content management system, besides the traditional classification system, Tag tags are undoubtedly a powerful tool to enhance the mesh connection of content and improve the efficiency of content discovery.AnQiCMS deeply understands this, and its built-in Tag label feature provides us with a powerful and flexible content operation tool.

2025-11-07

Does AnQiCMS's document tag (Tag) support cross-content model usage?

Does the document tag of AnQiCMS support cross-content model usage?—— The flexibility and depth of content operation As an experienced website operation expert, I have a deep understanding of the various functions of AnQiCMS (AnQiCMS), especially its unique design in content management.Today, let's discuss a topic that is of great concern in content management systems: Does AnQiCMS's document tag (Tag) support cross-content model usage?The answer is affirmative.

2025-11-07

How to limit the number and sorting method of displayed Tags using the `tagList` tag?

## Mastering Website Tags: The Quantity Limit and Sorting Tips of tagList in AnQi CMS In a content management system, tags (Tag) are an important element for connecting content, enhancing user experience, and optimizing search engine crawling.AnQi CMS is an efficient enterprise-level content management system that provides powerful tag management functions and allows developers and operators to flexibly display these tags on the front end through its template tag system.Among them, the `tagList` tag is the core tool for displaying the document related tag list.

2025-11-07

How to filter and display the Tag list based on index letters in AnQiCMS template?

Hello, users of AnQiCMS!As an experienced website operations expert, I know that in today's increasingly rich content environment, how to efficiently manage and display content is the key to improving user experience and optimizing SEO.Today, let's talk about a very practical feature in AnQiCMS: how to filter and display the Tag list in templates based on index letters, making your website content navigation smarter and more convenient.

2025-11-07

Can the `tagList` tag only display Tags associated with specific document IDs?

In the actual operation of AnQi CMS, how to manage content efficiently and accurately is the key to enhancing website value.Tags (Tag) are an important tool for content organization, allowing users to quickly find relevant information and greatly optimize the search engine's ability to crawl and understand website content.Many operators have a question when using the `tagList` tag of AnQi CMS: Can it only display tags associated with a specific document ID, rather than displaying all tags or tags on the current page?Today, let's delve deeply into this issue.

2025-11-07

How to call the Tag data of a specified site in AnQiCMS multi-site mode?

As an experienced website operations expert, I know that how to efficiently and accurately call data while managing multiple content platforms is the key to improving operational efficiency.AnQiCMS, with its excellent multi-site management features, has solved many such challenges for us.Today, let's delve into how the `tagList` tag in the multi-site mode of AnQiCMS can flexibly call the Tag data of a specified site to ensure the accuracy of content operation.### SecureCMS Multi-Site Capabilities Overview First

2025-11-07