Does AnQiCMS's `tagDataList` support excluding documents with a specific `moduleId`?

Calendar 👁️ 61

As a senior website operation expert, I know that AnQiCMS is powerful and flexible in content management.In daily content operations, we often need to control the displayed content in a refined manner. Tags (Tag) as an important dimension of content organization, the flexibility of their calling method is crucial.Today, let's delve into a frequently asked question: AnQiCMS'stagDataListDoes the tag support excluding specificmoduleIddocuments?

RevelationtagDataList: Does AnQiCMS support filtering bymoduleIddocuments?

AnQiCMS with its efficient and flexible content management capabilities is loved by a large number of webmasters and operators.tagDataListAs one of its powerful template tags, it is mainly used fortagIdGet the associated document list, which greatly facilitates the construction of tag-based aggregation pages or recommended content. However, in utilizingtagDataListWhen displaying content tags, many users may encounter a problem: does it support the direct exclusion of specificmoduleId(Model ID) documentation? Simply put, currentlytagDataListthe design of tags,Not provided directlyexcludeModuleIdThis parameter is used to exclude documents with specific model IDs.

Let's review firsttagDataListThe core functions and supported parameters of the tag. According to the official documentation of AnQiCMS,tagDataListThe tag is mainly used to retrieve the document list under a specified Tag, it supports the following key parameters:

  • tagId: Specify the Tag ID, which is the most core parameter.
  • moduleId: This parameter can help usincludeDocuments from a specific document model. For example, setmoduleId="1"You can only retrieve article model documents associated with the tag
  • order: Specify the sorting rules of the document.
  • limit: Control the number of documents displayed.
  • type: Define the list type, such as pagination (page) or a regular list (list)
  • siteId: If it is a multi-site mode, you can specify the site ID.

From these parameters we can clearly see,moduleIdThe function is to "include" or "filter out" documents with specific model IDs, rather than "exclude". This means that if you want the content under a certain tag not to display documents from the "Product Model", andtagDataListOnly the option to select the 'Article Model' is provided, without a direct path to 'Not select the Product Model'.

This is similar to some other list labels in AnQiCMS, such asarchiveListprovided byexcludeCategoryId(Exclude Category ID) Parameter for comparison,archiveListCan flexibly exclude specific category content, but even inarchiveListthere is no directexcludeModuleIdThe parameter indicates that AnQiCMS, in its design, may be more inclined to handle exclusion operations at the module level, or encourage more refined differentiation through content categorization.

flexible response: implementationmoduleIdexclusion strategy

AlthoughtagDataListThere is no directexcludeModuleIdHowever, as a senior operator, we are always able to find flexible solutions. Here are several practical strategies that can help you achieve specific features in AnQiCMS.moduleIdDocument exclusion:

1. Use template logic for post-filtering (most commonly used and recommended)

This is the most direct and flexible method. You cantagDataListAfter obtaining all document data associated with the tag, in the template'sforAdd conditional judgment in the loop to filter out unnecessary model ID documents.

  • Implementation steps:

    1. UsetagDataListLabel normally retrieves all documents under the specified tag without specifyingmoduleIdparameters, or only specify the main set you want to includemoduleId.
    2. While traversing in a looparchives(or you define other variables) when using{% if %}Tag judgmentitem.ModuleIdIs the ID you want to exclude
    3. Ifitem.ModuleIdIf not equal to the excluded ID, the document content is displayed normally
  • Code example:Assuming you want to display the label ID of1document, but to excludemoduleIdWith2(assuming it is a product model) document.

    <div class="tag-documents-list">
        {% tagDataList archives with type="page" tagId="1" limit="10" %}
            {% for item in archives %}
                {%- if item.ModuleId != 2 %} {# 排除 moduleId 为 2 的文档 #}
                    <div class="document-item">
                        <h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
                        <p>{{ item.Description }}</p>
                        {# 更多文档详情... #}
                    </div>
                {%- endif %}
            {% empty %}
                <p>当前标签下没有可展示的文档。</p>
            {% endfor %}
        {% endtagDataList %}
    
        {# 如果需要分页,分页标签仍然可以正常使用 #}
        {% pagination pages with show="5" %}
            {# 分页代码,此处略 #}
        {% endpagination %}
    </div>
    
  • Advantage:Implementation is simple, no need to modify the core system code, high flexibility, can be combined with complex logic for judgment (such as excluding multiple at the same time)moduleIdor excluding specificmoduleIdbelow specificcategoryIddocument).

  • Shortcomings:In cases where the number of associated documents is very large and a high proportion of documents need to be excluded, it may first load more data into memory for filtering, theoretically less efficient than querying and filtering directly on the backend.But for most websites, this performance overhead can be ignored.

2. Adjust content operation strategy

From the perspective of content operation and website architecture, if the content under a certain tag always needs to exclude documents of a specific model, this may suggest that your content organization structure can be further optimized.

  • Consider refining the tags:Can you create more specific tags to avoid this conflict?For example, if the "Promotion" tag is associated with both "Articles" and "Products", but you only want to display "Promotion Articles" on a specific page, you can consider creating two tags: "Promotion Articles" and "Promotion Products".
  • Utilize the classification model:The tag itself is cross-model, while the category is bound to a specific model. If the content attribute naturally belongs to a certain model, it can make more use of the category to do so

Related articles

How to call the list of all tags associated with the current document on the document detail page?

As an experienced website operations expert, I know the essence of content operations lies in how to organize information efficiently and present it to readers in the most intuitive and practical way.In AnQiCMS (AnQiCMS) such a powerful, SEO-friendly content management system, taking full advantage of its template tag system can greatly enhance the user experience and search engine performance of the website.Today, let's delve into a very practical scenario in content operation: how to call the list of all associated tags of the current document on the document detail page.

2025-11-07

Can AnQiCMS's `tagList` tag implement the 'weight' sorting or popularity display for Tag?

As an experienced website operations expert, I fully understand your need to sort the 'weight' or display popularity of the Tag feature in AnQiCMS (AnQiCMS).This not only concerns the SEO performance of the website, but is also the key to improving user experience and guiding content discovery.AnQi CMS, with its efficient and customizable features, provides us with a powerful content management foundation, but when it comes to the weight sorting of tags, we need to delve into its existing functions and potential expansion solutions.

2025-11-07

How does AnQiCMS handle URL conflicts for custom tags to ensure uniqueness?

As an experienced website operations expert, I know that every URL is crucial for the healthy operation of the website and search engine optimization (SEO).A clean, unique, and meaningful URL not only enhances user experience but is also the foundation for search engines to understand and index content.In AnQiCMS (AnQiCMS) such a content management system that focuses on SEO and efficient management, the uniqueness of the URL is naturally one of its core design considerations.Today, let's delve into a specific issue that may be encountered in operation: when you set a custom URL for Tag, if a conflict occurs

2025-11-07

How to determine whether the current page is a detail page of a specific Tag in AnQiCMS template?

## Deep Dive into AnQiCMS Template: How to Determine if the Current Page is a Detail Page for a Specific Tag In the flexible world of AnQiCMS, providing customized content and layout for different types of pages is crucial for enhancing user experience and optimizing SEO.Especially for the Tag (tag) page, we often need to present specific introductions, recommended articles, or unique styles based on the currently displayed Tag.How can we accurately determine whether the current page is a specific Tag detail page in the AnQiCMS template?

2025-11-07

How to display the Tag of a specific document on a non-Tag page through the `tagList` and `itemId` parameters?

As an experienced website operations expert, I know that how to flexibly display information in a content management system is crucial for improving user experience and website SEO.AnQiCMS (AnQiCMS) provides great freedom for content operators with its powerful template tag system.Today, let's delve into a very practical scenario: how to accurately display tags associated with specific documents on non-label aggregation pages (such as article detail pages or list pages).

2025-11-07

Can the Tag label be combined with the 'Content Collection' function of AnQiCMS?

## Smart Collection: The Path of Collaborative Operation between Anqi CMS Content Collection and Tag Tags In this era of information explosion, the speed and quality of website content updates directly determine its visibility in search engines and its value in users' hearts.For the vast majority of small and medium-sized enterprises, self-media operators, and teams that need to manage multiple sites, efficiently obtaining and organizing content is undoubtedly a huge challenge.AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language, with its high performance, flexible customization, and SEO-friendly features

2025-11-07

How to troubleshoot template or URL configuration problems when the Tag page in AnQiCMS opens abnormally?

As an experienced website operations expert, I deeply understand the unique advantages that AnQiCMS demonstrates in providing efficient content management for small and medium-sized enterprises and content operation teams.It relies on the high performance, flexible content model brought by the Go language, as well as the deep optimization for SEO, and has become a powerful tool in the hands of many operators.However, even the most powerful system is bound to encounter some minor hiccups in use, such as the Tag page not displaying normally, which often confuses operation personnel.The Tag page, as an important part of AnQiCMS content organization and SEO strategy

2025-11-07

Why doesn't the front end display immediately after adding a new Tag in AnQiCMS?

As an expert who has been deeply involved in website operations for many years, I know that every detail in a content management system can affect the final presentation of the website.I completely understand the feeling of confusion and anxiety when you carefully add a new Tag label in the AnQiCMS backend, only to find that it is not displayed on the front end for a long time.AnQiCMS with its high efficiency, flexibility, and SEO-friendly features has become the preferred choice for many content operators. Understanding some of the underlying mechanisms behind it can help us navigate it more smoothly.

2025-11-07