How to exclude specific category content from the document list?

Calendar 👁️ 68

In website operation, we often need to flexibly control the display of content.For example, you may want to display the latest articles on the homepage, but not include a specific category, such as "Internal Notice" or "Archived Content";Or in a product list, you want to exclude those categories that are 'discontinued' or 'internal testing' to keep the user interface simple and clear.

Safe CMS provides very convenient and powerful features to meet such needs. By skillfully using template tags in thearchiveListWe can easily exclude specific categories of content in the document list, making your website content more accurate and organized.

Precise control: How to exclude specific category content?

Of Security CMSarchiveListThe tag is the core tool we use to call the document list in the template.It is feature-rich and can filter and sort documents based on various conditions.When we want to exclude a specific category from a document list,archiveListThe tag provides a very practical parameter -excludeCategoryId.

This parameter allows you to specify one or more category IDs to remove documents under these categories from the current list.

Actual operation example:

1. Exclude a single category

Assuming your website has a category named "Internal Announcement" with category ID 5. You want to exclude the content of this category from all article lists, then you canarchiveListUse this label:

{% archiveList archives with type="list" limit="10" excludeCategoryId="5" %}
    {% for item in archives %}
        <li>
            <a href="{{item.Link}}">{{item.Title}}</a>
            {# 这里是其他文档信息,例如简介、发布时间等 #}
            <div>{{item.Description}}</div>
            <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
        </li>
    {% empty %}
        <li>
            该列表没有任何内容
        </li>
    {% endfor %}
{% endarchiveList %}

In this code block,excludeCategoryId="5"Tell the system to ignore articles with category ID 5 when retrieving the list of articles.

2. Exclude multiple categories

If you need to exclude multiple categories, such as the category ID 5 'Internal Announcement' and category ID 8 'Expired Activities', just separate these category IDs with commas:

{% archiveList archives with type="list" limit="10" excludeCategoryId="5,8" %}
    {% for item in archives %}
        <li>
            <a href="{{item.Link}}">{{item.Title}}</a>
            {# 您的文档列表循环代码 #}
        </li>
    {% empty %}
        <li>
            该列表没有任何内容
        </li>
    {% endfor %}
{% endarchiveList %}

By this means, you can flexibly combine the categories that need to be excluded to meet more complex display requirements.

3. Use with other filtering conditions.

excludeCategoryIdThe parameter can be used with otherarchiveListParameters perfectly combined. For example, you may only want to display articles under the 'Product Update' category with ID 10, but at the same time, you want to exclude the content of a subcategory 'Old Version Product' (assuming ID 12):

{# 假设您只想显示分类ID为10的“产品更新”下的文章,但排除其子分类“旧版本产品” (ID 12) #}
{% archiveList archives with type="list" categoryId="10" excludeCategoryId="12" limit="10" %}
    {% for item in archives %}
        <li>
            <a href="{{item.Link}}">{{item.Title}}</a>
            {# 您的文档列表循环代码 #}
        </li>
    {% empty %}
        <li>
            该列表没有任何内容
        </li>
    {% endfor %}
{% endarchiveList %}

Thus, you have achieved the need to further refine and exclude certain subcategories under a specific parent category.

How to find the category ID?The category ID can be found on the 'Content Management' -> 'Document Category' page in the AnQi CMS backend.Each category will display its unique ID next to it, making it convenient for you to configure.

Practical scenarios and advanced skills:

  • Keep the content fresh:On the homepage of the website, in the 'Latest Articles' or 'Hot Recommendations' area, you can exclude some categories that have not been updated for a long time or are outdated, ensuring that the content shown to users is always the latest and most relevant.
  • Optimizing user experience: Under the website navigation menu, in the content preview or related recommendation module, exclude categories such as internal management and copyright statements that are not suitable for direct display to ordinary users, making the content stream more focused.
  • SEO strategy:Sometimes to avoid certain low-quality or repetitive content from affecting the overall SEO weight of the website, it can be done byexcludeCategoryIdExclude pages under these categories from the core content list to better focus on optimizing important content.
  • Content aggregation under multi-site management:If you have used the multiple site management feature of AnQi CMS and want to aggregate the content of other sites on one site, while excluding certain specific categories,excludeCategoryIdIt can also help you control the source of content more accurately.

By flexible applicationexcludeCategoryIdThis parameter allows you to finely control the display logic of website content, improving the user experience and operational efficiency of the website.


Frequently Asked Questions (FAQ)

1.excludeCategoryIdCan I exclude the top-level category only?

No,excludeCategoryIdParameters can exclude any level of categorization. As long as you provide the accurate ID of the category, whether it is a top-level category or a multi-level subcategory, the system will exclude the documents under it from the list.

2. If I exclude a parent category, will its subcategories still be displayed?

excludeCategoryIdThe parameter is for excluding the explicitly specified category ID. If you exclude a parent category but do not exclude its subcategories, then the documents directly associated with the parent category will be excluded, but the documents under the subcategory will still be based on other conditions such ascategoryIdIf the parameter is specified, the parent category) is displayed. To exclude the parent category and all its subcategories, you need to list all relevant category IDs.excludeCategoryId.

3. I want to exclude a specific subcategory of documents under the current category on a category page, how do I operate?

On the category list page,archiveListTags usually automatically obtain the ID of the current category to display the content. In this case, you can specifycategoryIdparameters (for the system to automatically identify the current category), and then go throughexcludeCategoryIdThe parameter explicitly specifies the subcategory ID you want to exclude. As a result, the document list on the current category page will not include the content of that excluded subcategory.

Related articles

How to filter document lists in AnQi CMS based on recommended attributes (such as headlines, recommendations)?

AnQi CMS as an efficient content management system, provides rich functions to help operators manage and display website content.Among the "recommended properties" feature is a very practical tool, which allows us to flexibly mark documents, thereby realizing dynamic filtering and display of specific content in different areas of the website.This article will discuss in detail how to use recommended attributes to filter document lists in AnQi CMS, making the website content more dynamic and attractive.

2025-11-08

How to sort the document list of Anqi CMS by views or publish time?

How to effectively organize and present content in website construction and operation is the key to improving user experience and content discovery efficiency.For friends using AnQiCMS, it is very practical to flexibly sort the document list.Whether it is to make visitors see the most popular articles first or the latest updates, AnQiCMS provides a simple and powerful way to achieve this.

2025-11-08

How can AnQi CMS display a list of documents under a specified category and perform pagination?

AnQiCMS (AnQiCMS) with its flexible template mechanism and powerful content management features makes the display of website content very simple and efficient.For many websites, clearly displaying content by category and providing convenient pagination navigation is the key to improving user experience and optimizing search engine rankings.Let's learn together how to easily implement document list display and pagination functions under specified categories in Anqi CMS.### Flexible configuration, control content display Anqi CMS template system uses syntax similar to Django template engine

2025-11-08

How to display content from a specific site by using label parameters in a multi-site environment?

When using AnQiCMS for website management, the multi-site feature undoubtedly brings great convenience to users with multiple brands, sub-sites, or content branches.It allows us to efficiently manage multiple independent websites on a unified backend.However, in actual operation, we sometimes encounter a specific requirement: to display the content of another specific site on a site.For example, the main site wants to reference some of the latest articles from the child site, or a specific thematic site wants to display product information from another cooperative site.At this moment, 'How to set up an environment across multiple sites'

2025-11-08

How to achieve accurate display of in-site search results in Aiqi CMS?

The importance of on-site search functionality in daily website operation is self-evident.It is not only a bridge for users to quickly find the information they need, but also a key link to improve user experience, extend visit duration, and even promote conversion.If a user enters a keyword and gets a bunch of irrelevant results, they are likely to leave quickly.Therefore, how to achieve accurate display of in-site search results in AnQiCMS is a topic that every content operator should delve into.AnQiCMS is a system specially designed for content management, with a powerful and flexible search mechanism and content organization capabilities

2025-11-08

How to retrieve and display the complete content and all fields of a single document?

One of the core values of a content management system is the ability to flexibly define and present various types of content.For users of AnQiCMS, whether it is to display a detailed article, a product page, or a custom data entry, how to efficiently obtain its complete content and all associated fields is the key to front-end template development and content presentation.Today, let's delve into how to easily control the acquisition and display of individual document content in AnQiCMS using this '万能钥匙' template tag.

2025-11-08

How can AnQi CMS enable lazy loading display for images in document content?

In today's online environment, the loading speed of a website is one of the key factors in user experience and search engine ranking.When web page content includes a large number of images, these images often become the 'culprits' that slow down loading speed.Imagine a user opening a page, even if they haven't scrolled to the bottom of the page, the browser has already started downloading all the images, which undoubtedly consumes valuable bandwidth and processing resources, resulting in slow page response.In order to solve this pain point, the Lazy Loading technology for images was born.

2025-11-08

How to get the title list (H1-H6) of document content for generating catalog navigation?

In the daily operation of websites, we often encounter long-form content, such as tutorials, product descriptions, or in-depth analysis articles.It is particularly important to add a clear table of contents to the article at this point (usually located in the sidebar or at the top of the article).It can not only help visitors quickly understand the structure of the article, jump directly to the part of interest, but also improve the page SEO performance, enhance the user experience.In AnQiCMS (AnQiCMS), implementing this feature is actually simpler than you imagine, thanks to a very practical template tag provided by the system.

2025-11-08