During the operation of the website, we often need to manage and display content in a refined manner.For example, we may want to hide certain internal announcements, specific promotional content, or some draft category articles that are not suitable for external display when recommending articles on the homepage.AnQiCMS (AnQiCMS) is a powerful content management system that fully considers such needs and provides a simple and flexible way to achieve this - by specifying exclusion parameters in the document list tag.
This article will delve into how to exclude certain specific category articles from the document list in AnQiCMS, helping you more effectively control content display and optimize the user experience.
Precision control: Exclude specific category articles from the AnQiCMS document list
One of the core advantages of Anqi CMS lies in its flexible content management and template tag system. When you need to display a list of articles on the front page of the website, you will usually usearchiveListThis powerful template tag. It can not only help you filter articles of specific categories, sort by various conditions, but also easily exclude articles from category classification.
Core tool:excludeCategoryIdParameter
To implement the classification exclusion of document lists, AnQiCMS provides a very intuitive and powerful parameter:excludeCategoryId. By definition, this parameter allows you to specify one or more unique category IDs, so that articles under these categories will not appear in the current document list.
How to find the category ID?
In the Anqi CMS backend, you can easily find the unique ID of each category.
- Log in to your AnQiCMS background.
- Navigate to 'Content Management' -> 'Document Categories'.
- In the category list, each category entry will display an "ID" column.This is the category ID you need to use. Moreover, when editing a category, the URL in the browser address bar will also contain the category ID (for example:
.../category/edit?id=10Here, 10 is the category ID).
How to use in the templateexcludeCategoryId?
Once you have determined the category ID to exclude, you can apply it to your template file."),archiveListin the tags.
Basic usage: Exclude a single category.
Assuming you want to exclude articles with ID10from the 'Internal Announcement' category. YourarchiveListtag can be written as:
{% archiveList archives with type="page" limit="10" excludeCategoryId="10" %}
{# 在这里循环显示您的文章内容 #}
{% for item in archives %}
<li>
<a href="{{item.Link}}">
<h5>{{item.Title}}</h5>
<p>{{item.Description}}</p>
<span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
</a>
</li>
{% empty %}
<li>当前没有可显示的文章。</li>
{% endfor %}
{% endarchiveList %}
Advanced usage: Exclude multiple categories
If you need to exclude multiple categories at the same time, for example, ID is10of 'Internal Announcement' and ID is12of 'Draft' category, you just need to separate these category IDs with commas:
{% archiveList archives with type="page" limit="10" excludeCategoryId="10,12" %}
{# 在这里循环显示您的文章内容 #}
{% for item in archives %}
<li>
<a href="{{item.Link}}">
<h5>{{item.Title}}</h5>
<p>{{item.Description}}</p>
<span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
</a>
</li>
{% empty %}
<li>当前没有可显示的文章。</li>
{% endfor %}
{% endarchiveList %}
excludeCategoryIdwithcategoryIdto be used together
excludeCategoryIdParameters can be used withcategoryIdUsing parameters in conjunction, achieve more refined filtering. For example, you might want to filter only in the "News Center" (assuming ID is1Below display articles, but exclude "Industry Activities" within "News Center" (assuming ID of5) articles of this subcategory.
In this case,categoryIdFirst, filter out all articles under the 'News Center' and its subcategories (ifchildthe parameter is true, the default is true), thenexcludeCategoryIdexclude articles with category ID5's article.
{% archiveList newsArticles with type="page" categoryId="1" excludeCategoryId="5" limit="10" %}
{# 显示属于分类ID 1,但不属于分类ID 5 的文章 #}
{% for item in newsArticles %}
<li>...</li>
{% empty %}
<li>没有找到符合条件的新闻文章。</li>
{% endfor %}
{% endarchiveList %}
Practical suggestions and precautions
- Please specify the category ID:Before modifying the template, please ensure that the category ID you want to exclude is accurate. An incorrect ID may lead to unexpected results.
- Content existence:Please note,
excludeCategoryIdJust control content:Front-end displayThis content is not deleted. The excluded articles still exist in your AnQiCMS system and can be accessed directly via their URL. - Used in multiple places:If your website displays article lists in multiple places (such as the homepage, sidebar, specific topic pages, etc.) and you want to apply the same exclusion logic in all these places, you need to set it in each relevant
archiveListAdd tags toexcludeCategoryIdParameter. - SEO consideration:If the excluded category articles are ones you don't want to be crawled by search engines, simply by
excludeCategoryIdIt is not enough to hide on the front end. You may need to combine the AnQiCMS Robots.txt configuration or the article detail page settings to prevent search engines from indexing.noindexSet to block search engine indexing.
by masteringexcludeCategoryIdParameter, you can manage the content presentation on AnQiCMS website more flexibly and accurately, ensuring that visitors always see the article list that best suits your operational strategy.
Frequently Asked Questions (FAQ)
Q1:excludeCategoryIdWhether the parameter will affect the SEO performance of the article?
A1:excludeCategoryIdMainly controls the article in a specific list.Front-end display. The article itself is still accessible if there is a URL link available and it has not been blocked by Robots.txt ornoindexTags and SEO means to prevent, search engines can still crawl and index these articles. If you do not want certain category articles to be indexed by search engines, it is recommended to add advanced SEO settings through the background "Document Category" editing page or the individual article editing pagenoindexTags, or configure them in the AnQiCMS Robots.txt management.
Q2: If I exclude a parent category, will all subcategory articles also be automatically excluded?
A2:excludeCategoryIdThe parameter directly affects the category ID associated with the article. If you exclude the ID of a parent category (for example, ID 10), then the articles directly belonging to ID 10 will be excluded.If the article of the subcategory itselfCategoryIdIs a subcategory ID (for example, if ID 11 is a subcategory of ID 10), unless you also specifyexcludeCategoryIdID 11 explicitly in it, otherwise these subcategory articlesWill not be automatically excludedTo ensure the entire category tree is excluded, you may need to manually list all the parent and child category IDs related to it.
Q3: BesidesexcludeCategoryIdWhat are some parameters that can help me refine the article list?
A3: AnQiCMS'archiveListTags provide various powerful filtering parameters:
categoryId: Specify the category ID(s) to include (multiple IDs can be separated by commas).moduleId: Based on the article