How to filter documents of specific models in the Tag document list of AnQiCMS template?

Calendar 👁️ 74

As an experienced website operations expert, I know that the flexibility of the Content Management System (CMS) is the key to improving operational efficiency and meeting diverse business needs.AnQiCMS (AnQiCMS) relies on its powerful content model and template system, providing great convenience for content operation.Today, let's delve deeply into a very practical scenario in actual operation: how to accurately filter documents of a specific content model from the Tag document list in AnQi CMS template.

Flexibly control content: AnQi CMS' 'Model' and 'Tag'

In Anqi CMS, the core of content management lies in the two major functions of "content model" and "tags." Understanding them is the premise for precise filtering.

Content modelAs the name implies, it is the basis for defining the structure of different types of content.Whether it is a common "article", or a "product" with attributes such as price and inventory, or other custom "events", "cases", and model, they all have their own unique fields.Flexible content model design of Anqi CMS (such asAnQiCMS 项目优势.mdThe 'Allow users to customize content models based on business requirements' mentioned enables us to create dedicated management and display structures for different types of content. For example, the default 'Article Model' and 'Product Model' (refer tohelp-content-module.mdEach has its own characteristics.

AndTagThis is a cross-model, cross-category content classification method.It allows us to associate documents with the same topic, keywords, or attributes without being limited by traditional hierarchical classifications.For example, a 'new product launch' tag may be associated with the 'article' introducing the new product, as well as the 'product' page of the new product.help-content-tag.mdIt also mentions that document tags are not categorized by type and model, the same tag can be used to mark documents of different content models at the same time.This flexibility is particularly important in content marketing and SEO strategies.

When these two powerful functions are combined, we can build a website content system that is both clear in structure and rich in theme.But sometimes, we may wish to display only documents under a specific model when displaying content under a certain Tag, such as only displaying specific new products (product model) on a 'New Products Launch' Tag page, rather than market analysis articles (article model) about new products.This is when it needs to be usedtagDataListThe filtering ability of the tag.

Core decryption:tagDataListThe 'model' filtering ability of the tag.

In the Anqi CMS template system, the core tag used to call the document list under Tag is{% tagDataList %}. According todesign-tag.mdandtag-/anqiapi-tag/149.htmlThis label provides various parameters to customize the document display style. The key parameter for solving our problem ismoduleId.

moduleIdThe parameter allows you to specify the specific content model ID to retrieve the document list. This means that even if a Tag is associated with documents under multiple content models, you can setmoduleIdYou can also easily filter it out and only display the part you want.

Practice exercise: Filter specific model documents

Now, let's look at a real example to see how to use it in a templatemoduleIdfor filtering.

Step 1: Determine the target model ID

Firstly, you need to know the ID of the 'content model' you want to filter. You can find it by following these steps in the Anqi CMS backend:

  1. Log in to the AnQi CMS background.
  2. Navigate toContent Management -> Content Model.
  3. Here, you will see all the content models created (including the system default 'Article Model' and 'Product Model', as well as any custom models you have created).Each model will have a corresponding ID.
    • Usually, the ID of the 'article model' is1The ID of the 'Product Model' is2.
    • Remember the numerical ID of the target model you are looking for, for example, we assume we want to filter the 'Product Model', whose ID is2.

Second step: Write template code for filtering

Suppose we are editing the Tag document list page (for exampletag/list.html),and hope to display all documents belonging to the "product model" under the current Tag on this page.

We will usetagDataListTag, and join.moduleId="2"To specify the filtering of product models.

”`twig {# First, get the details of the current Tag, which is usually available by default in the tag/list.html template #} {# If it's not tag/list.html, you may need to use the tagDetail tag to get the current TagID, for example, {% tagDetail currentTag with name=“Id” %} #}

Current tag: {% tagDetail with name="Title" %}

{# Use the tagDataList tag and explicitly specify moduleId as 2 (product model) #} {% tagDataList archives with type=“page” limit=“10” moduleId=“2” %}

{% for item in archives %}
    <div class="product-item">
        <a href="{{item.Link}}">
            {% if item.Thumb %}
                <img src="{{item.Thumb}}" alt="{{item.Title}}">
            {% else %}
                <img src="{% system with name='TemplateUrl' %}/images/default-product.png" alt="默认产品图">
            {% endif %}
            <h3>{{item.Title}}</h3>
        </a>
        <p>{{item.Description|truncatechars:80}}</p>
        {# 假设产品模型有自定义字段“price”,可以通过 item.price 调用 #}
        {# 可以在这里进一步调用产品模型的特有字段,例如:{{item.price}} #}
        <span class="view-count">{{item.Views}} 浏览</span>
        <span class="publish-date">{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
    </div>
{% empty %}
    <p>当前标签下,产品模型没有任何相关文档。</p>
{% endfor %}

{# 如果 type="page",则需要配合分页标签显示分页 #}
{% pagination pages with show="5" %}
    <div class="pagination-nav">
        {% if pages.FirstPage %}<a href="{{pages.FirstPage.Link}}">首页</a>{% endif %}
        {% if pages.PrevPage %}<a href="{{pages.PrevPage.Link}}">上一页</a>{% endif %}
        {% for page_item in pages.Pages %}
            <a class="{%

Related articles

What is the actual use of the index letter of Tag tags in AnQiCMS?

As an experienced website operations expert, I am well aware that every detail function of the content management system (CMS) can become the key to improving website operation efficiency and optimizing user experience.AnQiCMS (AnQiCMS) provides us with many such 'tools' with its concise and efficient architecture, and among them, the 'index letter' function of the Tag label, although seemingly minor, plays a crucial role in content operation strategy.Today, let's delve into the practical uses of this feature.

2025-11-07

How to customize the URL alias of Tag tags in AnQiCMS to improve SEO?

As an experienced website operations expert, I know that every detail can affect the search engine performance of a website.In a highly efficient and flexible content management system like AnQiCMS, even seemingly minor settings such as the URL alias of Tag tags contain great SEO optimization potential.Today, let's delve into how to customize the URL alias of Tag tags in AnQiCMS, so that your website can be more competitive in search engines.Unlock the URL customization power of Anqi CMS Tag tag

2025-11-07

How to set SEO optimization (SEO title, keywords, description) for AnQiCMS Tag tags?

##驾驭AnQiCMS Tag: In-depth Analysis of SEO Optimization Settings (SEO Title, Keywords, Description) As an experienced website operations expert, I know that in today's fiercely competitive online environment, Search Engine Optimization (SEO) is the cornerstone of website success.AnQiCMS is an enterprise-level content management system developed based on the Go language, which has always attached great importance to SEO and considers it the cornerstone for enterprises and content operation teams.Today, we will delve into a powerful yet often overlooked SEO tool in AnQiCMS——Tag tag

2025-11-07

How to add a new document tag in the AnQiCMS backend management?

As an experienced website operations expert, I am well aware of the powerful and convenient content management capabilities of AnQiCMS.Label, this seemingly insignificant feature is actually a powerful tool for connecting content, enhancing user experience, and optimizing search engine performance.Today, let's delve into how to add new tags flexibly and efficiently to your documents in the AnQiCMS backend management.

2025-11-07

How to get the thumbnail or Logo of Tag in AnQiCMS template?

As an experienced website operation expert, I am well aware that how to flexibly use template tags to display a variety of content in a content management system is the key to enhancing the attractiveness and user experience of a website.AnQiCMS with its concise and efficient architecture and powerful template functions, provides us with great convenience.Today, let's delve into a common and practical need in content operation: how to obtain the thumbnail or Logo of a Tag in the AnQiCMS template.

2025-11-07

What control flow tags does AnQi CMS template language support (such as if, for)?

## AnQi CMS template language: if, for, allowing flexible control of content display As an experienced website operation expert, I deeply understand the importance of a flexible and efficient content management system to a company.AnQiCMS (AnQiCMS) stands out in the content operation field with its high-performance architecture based on the Go language and its highly customizable nature.In daily content display and page construction, control flow tags in template languages, such as `if` and `for`, are undoubtedly the core tools for us to achieve dynamic and personalized content presentation. Today

2025-11-07

How to use a for loop to iterate over a data list in AnQiCMS template?

## Master AnQiCMS Templates: The Art of Using `for` Loops to Traverse Data Lists Hello, all AnQiCMS operation partners!In daily website content operations, we often need to display a series of data, whether it is the latest article list, product category navigation, or comment details, it is inseparable from the traversal and display of the data set.AnQiCMS as an efficient and flexible content management system, deeply understands the importance of templates in content presentation. Today

2025-11-07

How to determine if a variable is empty or execute conditional logic in AnQiCMS templates?

As an experienced website operation expert, I am well aware of how crucial precise control of template logic is when building and maintaining a high-efficiency, user-friendly website.Especially when using a content management system like AnQiCMS, which is based on Go language and focuses on performance and flexibility, it is possible to flexibly judge the status of variables and execute conditional logic according to different situations, which is the foundation for ensuring the correct display of content, avoiding page errors, and improving the user experience.The template engine of AnQi CMS uses a tagging style similar to Django

2025-11-07