Does AnQiCMS support displaying the document list under a specific Tag on the front end?

In AnQi CMS, you can of course easily display the document list under a specific Tag (label) on the front end.This is not only a basic function of a content management system, but Anqi CMS also allows you to achieve this in a very fine and friendly way through its flexible template tag system, thereby better organizing content, improving user experience, and enhancing the SEO performance of the website.

Starting from version 2.1.0 of AnQi CMS, the system has introduced a powerful article and product Tag label feature, which means you can now add one or more tags to your content (whether it's articles or products), associating documents of different categories but related themes.These tags are not just tools for backend management; they are designed to be displayed and interacted with directly on the front end, becoming an important way for users to discover content.

To implement the front-end display of document lists under a specific Tag, the built-in template tags of Anqi CMS will be mainly used:tagList/tagDetailandtagDataListThey work together, allowing you to build a fully functional tag page.

first, tagListTags are mainly used to get all the tags list on your website, or a limited number of commonly used tags.You can use it in the website sidebar, footer, or a dedicated tag cloud page to display various tags that users may be interested in.

When the user clicks on a specific tag, they want to view all the documents under that tag.tagDetailTags can be put to use. It allows you to get detailed information about the specific tag, such as the name, description, and its exclusive link.This information can be used to build the tab page title and introduction, telling visitors which topic the current page is about.

The real core function, that is, getting the document list under a specific Tag, is to betagDataListThis tag is implemented. This tag is designed to display documents associated with a tag, and its usage is very intuitive and powerful.

When you create a tag list page (usuallytag/list.htmlSuch a template)tagDataListAutomatically detects the Tag ID contained in the current page URL and uses it to retrieve the corresponding document list. Of course, you can also usetagIdThe parameter specifies which document under which Tag to retrieve.

For example, if you want to display a list of articles under a specific tag and want to display 10 articles per page:

{# 假设这是标签列表页,系统会自动获取当前Tag的ID。我们先获取Tag的详情信息 #}
{% tagDetail currentTag with name="Title" %}
<h1>标签:{{ currentTag }}</h1>

{% tagDetail tagDescription with name="Description" %}
{% if tagDescription %}
<p>{{ tagDescription }}</p>
{% endif %}

<p>此标签下的相关文档:</p>
{% tagDataList archives with type="page" limit="10" %}
    {% for item in archives %}
    <article class="document-item">
        <h2><a href="{{ item.Link }}">{{ item.Title }}</a></h2>
        <p>{{ item.Description }}</p>
        <div class="meta-info">
            <span>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
            <span>阅读量:{{ item.Views }}</span>
            {# 可以在这里显示文档所属分类等信息 #}
            {% categoryDetail categoryTitle with name="Title" id=item.CategoryId %}
            <span>分类:{{ categoryTitle }}</span>
        </div>
        {% if item.Thumb %}
        <div class="document-thumb">
            <a href="{{ item.Link }}"><img src="{{ item.Thumb }}" alt="{{ item.Title }}"></a>
        </div>
        {% endif %}
    </article>
    {% empty %}
    <p>这个标签下暂时还没有文档哦!</p>
    {% endfor %}

    {# 如果需要分页,可以接着使用 pagination 标签 #}
    <div class="pagination-wrapper">
        {% pagination pages with show="5" %}
            {# 这里是分页链接的展示代码,您可以根据自己的样式需求进行调整 #}
            {% if pages.FirstPage %} <a href="{{ pages.FirstPage.Link }}">首页</a> {% endif %}
            {% if pages.PrevPage %} <a href="{{ pages.PrevPage.Link }}">上一页</a> {% endif %}
            {% for p in pages.Pages %}
                <a href="{{ p.Link }}" class="{% if p.IsCurrent %}active{% endif %}">{{ p.Name }}</a>
            {% endfor %}
            {% if pages.NextPage %} <a href="{{ pages.NextPage.Link }}">下一页</a> {% endif %}
            {% if pages.LastPage %} <a href="{{ pages.LastPage.Link }}">末页</a> {% endif %}
        {% endpagination %}
    </div>
{% endtagDataList %}

In the above code snippet,tagDataListIt will return a namedarchivesThe document array, you can useforLoop through this array, retrieve the title, link, description, publish time, reading volume of each document, and display them according to the front-end style you design. If there are no documents under the current tag,emptyThe content in the block will be displayed. At the same time,type="page"Parameter coordinationpaginationTags, can also realize the pagination function of the list, making content management more convenient, and avoid the impact of too long content on the loading speed and user experience.

Furthermore,tagDataListit also supportsmoduleIdParameters mean you can specify only to get the tag document list under a specific content model (such as the "article" model or "product" model), which provides great flexibility for websites with multiple content types.

In summary, Anqi CMS has a well-implemented and easy-to-use feature for displaying document lists under specific tags on the frontend.By flexibly using the template tags provided, you can not only efficiently manage and display content, but also greatly enhance the organization structure of website content, improve the user's experience in discovering content on your website, and help improve the search engine's crawling and understanding of website content.


Frequently Asked Questions (FAQ)

How to ensure that the URL of the Tag list page is SEO-friendly?The Anqi CMS provides pseudo-static rule management functionality, you can configure a custom URL structure for tag pages, for example/tag/标签名称.htmlor/tags/标签别名/Set it in the "Function Management" under the "URL Rewrite Rule" in the background, and make sure your template file (such astag/list.html) Match these rules to generate clear, readable, and SEO-friendly URLs.

2. Besides the document list, what information can I display on the Tag page?On the Tag page, in addition to the document list, you can also usetagDetailLabel to get more information about the current Tag, such as its SEO title, keywords, and description. This information can be used for the page's<head>Part, enhance the SEO performance of the page. In addition, you can alsotagListdisplay tags such as "Hot Tags" or "Tag Cloud" to guide users to discover more relevant content.

3. Can my website distinguish the display of Tag lists if it has multiple content models (such as articles and products)?Absolutely, you can.tagDataListTag supportmoduleIdParameters. You can set them up throughmoduleId="1"Get the documents associated with the current Tag under the article model, or setmoduleId="2"To get the document under the product model. This means you can flexibly display or merge the document list from different content models on the same Tag page.