As an experienced website operation expert, I know the importance of the accuracy of content display for user experience and website operation efficiency.In a content management system, we often encounter the need: when generating an article list, we need to exclude certain specific category documents to ensure the relevance and focus of the content.AnQiCMS (AnQiCMS) is an efficient and flexible content management tool that provides us with a very convenient solution.archiveListIn the tag, cleverly use parameters to exclude specific categories of documents to achieve precise content display.

When building website content, we may have various types of articles, such as news updates, product introductions, technical tutorials, company announcements, as well as test drafts or expired event information.If all the content is listed on a page without distinction, it may dilute the core information, distract the user's attention, and even affect the professional image of the website.For example, the homepage of a technology blog usually displays the latest technical articles, but we may not want to mix in documents such as 'internal team building activities' or 'website update logs' that are only for specific audiences.In this case, it is particularly important to accurately exclude certain categories.

AnQi CMS provides us with a flexible content call mechanism through its powerful template tag system. Among them,archiveListTags are the core tools used to retrieve various document lists, whether it is a regular article list, a paged list, or related documents associated with keywords, it can handle it. To achieve the purpose of excluding specific categories,archiveListA key parameter in the label -excludeCategoryIdIt is our powerful assistant.

excludeCategoryIdThe role of the parameter is very direct: it tellsarchiveListLabel, when querying documents, please ignore all documents under the specified category ID. This means that even if these documents meet other filtering conditions (such as model ID, recommendation attributes, etc.), as long as their category ID is listed underexcludeCategoryIdIt will not appear in the final list.

UseexcludeCategoryIdThe parameter is very simple.First, we need to know the ID of the categories to be excluded.This can be viewed on the "Content Management" -> "Document Category" page in the Anqi CMS backend.Each category has a unique numeric ID.Assuming we want to exclude the documents of the 'Company Internal Announcement' category with ID 5 and the 'Expired Activities' category with ID 12.

Next, we just need to find the template file that needs to be modified (such as the homepage of the website's)index.html, or some special list page'scategory/list.html) to find it.archiveListLabel, and add or modifyexcludeCategoryIdThis parameter can accept a single category ID, or multiple category IDs separated by commas.

Let us demonstrate with an actual code snippet:

{# 假设我们希望在网站首页展示最新的文章,但排除ID为5和12的分类文档 #}
<div>
    <h3>最新动态</h3>
    <ul>
        {% archiveList archives with type="list" limit="10" excludeCategoryId="5,12" %}
            {% for item in archives %}
                <li>
                    <a href="{{item.Link}}">{{item.Title}}</a>
                    <span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                    <span>浏览量:{{item.Views}}</span>
                </li>
            {% empty %}
                <li>抱歉,没有找到符合条件的文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In this example,type="list"Indicates retrieving a fixed number of lists,limit="10"Limited to displaying 10 articles, andexcludeCategoryId="5,12"It ensured that documents with category IDs 5 and 12 will not appear in this "latest news" list.This is the content that has been carefully selected and is more relevant, presented to the user.

Reasonably utilizing in actual operation,excludeCategoryIdParameters, help us better manage the lifecycle of content. For example, for some temporary promotional activities or internal materials, we can set up a separate category for them, and display them on the main list of the front end throughexcludeCategoryIdParameters are excluded.When this content is no longer needed to be exposed, there is no need to delete it either. Just make sure it is still excluded, which greatly reduces maintenance costs.At the same time, this exclusion mechanism has a relatively controllable impact on the website's SEO.The excluded document can still be found through other channels if it has an independent detail page and is indexed by search engines, and the refined list page can help improve the relevance of core keywords.

In short, the Anqi CMS'sarchiveListwith the tag andexcludeCategoryIdThe combination of parameters provides powerful content refining capabilities for website operators.By simple parameter configuration, we can achieve precise control in complex content structures, providing users with a better and more focused browsing experience, thereby enhancing the overall value of the website.


Frequently Asked Questions (FAQ)

Q1:excludeCategoryIdandcategoryIdCan parameters be used at the same time? What is their priority?

A1:Yes,excludeCategoryIdandcategoryIdParameters can be used at the same time. When you specify both of these parameters in aarchiveListtag, AnQiCMS will first check according tocategoryIdFilter documents under a specific category (i.e., "which categories include"), and then exclude them from this result setexcludeCategoryIdDocuments specified by the parameter. This meanscategoryIddefined the initial inclusive range, whileexcludeCategoryIdThen perform the "subtraction" operation within this range. This combination is very flexible and can help you build very precise content filtering logic.

Q2: If I want to exclude a lot of categories, is there a more concise method than listing all category IDs one by one?excludeCategoryIdCurrently?

A2:CurrentlyexcludeCategoryIdYou need to explicitly list the category IDs to be excluded (separated by commas). If the number of categories to be excluded is huge and difficult to manage, you can consider optimizing your content structure:

  1. Exclude parent category: Place all subcategories to be excluded under a specific parent category, and then you can try to exclude just that parent category. InarchiveListthe default behavior of tags, ifchild=true(Default value), excluding the parent category will also exclude all its child categories.
  2. Recommended attribute (Flag): For documents that you do not want to display, you can consider setting a specific "recommended attribute" (for example, a custom "hidden" attribute) during backend editing, thenarchiveListpass throughexcludeFlagParameters to exclude documents containing the property.
  3. Template logic judgment: If the above method does not apply, you can also inarchiveListUse within the loop,{% if item.CategoryId != 排除ID %}This logical judgment to skip documents that do not want to be displayed, but it will increase the complexity of the template and may affect performance, it is better to exclude efficiently in the tag parameters directly.

Q3: After excluding documents of a specific category, will these documents still be indexed by the search engine?

A3: excludeCategoryIdThe parameter only controls the display of the list on the front-end page, it does not directly interfere with the crawling and indexing behavior of search engines. If the excluded document itself has an independent detail page, and these detail pages do not setnoindex(Forbidden index) Meta tag, not indexedrobots.txtThe file is prohibited from being indexed by search engines, but search engines can still find and index these documents through other paths (such as Sitemap of the website, internal links on other pages, or even links from external websites). If you really do not want certain categories or documents to be indexed by search engines, it is recommended to set this at the level of the detail page or category page of these documents.noindexMetadata, androbots.txtconfigure accordingly.