As a senior security CMS website operator, I fully understand the core value of content tags in website content management and user navigation.A high-quality tag strategy can not only help readers quickly find the information they need, but also effectively improve the organization and SEO performance of website content.I will elaborate on how to flexibly use tags in the AnQiCMS template to display tag lists or document lists under specific tags.
Understand the content tags in AnQiCMS
In AnQiCMS, content tags (Tags) are a powerful content association tool that is independent of the classification system, allowing you to aggregate documents from different models or categories through common keywords.This flexibility makes content tags a key element in improving website content discovery, building related content networks, and optimizing user experience.AnQi CMS provides dedicated template tags, allowing you to easily display and manage these tags and the associated documents on the website front-end.
How to display the document's Tag list in the template
When you want to display a tag list in a certain area of the website, such as the sidebar, footer, or document detail page, you can usetagListThe tag can retrieve the tags associated with the current document, or all tags under the specifieditemId="0"parameters, or the entire site (or specified category) of all tags.
If you want to display the list of tags associated with the current document on the document detail page, the code will be very concise:
<div class="document-tags">
<strong>本文标签:</strong>
{% tagList tags %} {# 默认读取当前文档ID的标签 #}
{% for item in tags %}
<a href="{{item.Link}}" title="查看所有与“{{item.Title}}”相关的文档" class="tag-item">{{item.Title}}</a>
{% endfor %}
{% endtagList %}
</div>
This code will traverse all associated tags in the current document and generate a link containing their title and link.<a>elements.
If you want to display a global tag list on non-document detail pages of the website (such as the homepage, category list page, or sidebar), for example, "Hot Tags" or "Tag Cloud", you can do so byitemId="0"Specify parameters to retrieve all tags. You can also use parameters tolimitcontrol the number of tags displayed:
<div class="global-tags-cloud">
<h3>探索热门标签</h3>
{% tagList tags with limit="30" itemId="0" %} {# 获取全站最多30个标签 #}
{% for item in tags %}
<a href="{{item.Link}}" title="探索更多关于“{{item.Title}}”的内容" class="tag-cloud-item">{{item.Title}}</a>
{% endfor %}
{% endtagList %}
</div>
Here, limit="30"up to 30 tags can be displayed, and