As an experienced website operations expert, I know that the flexibility of the content management system is crucial for efficient operation.AnQiCMS (AnQiCMS) takes advantage of its powerful template tag system, providing us with great convenience.archiveListLabel, filter and display documents based on multiple category IDs to create more targeted and attractive content modules.

Flexible filtering: AnQiCMSarchiveListThe application of multi-class ID tags

In website content operation, we often need to display articles, products, or other documents from multiple related categories on a specific page.For example, you may want to display the contents of two categories, such as "Latest News" and "Hot ProductsIf only the content of each category can be called one by one, it is not only inefficient but also difficult to integrate and display the content in an interlaced manner.

AnQiCMS'archiveListThe tag is exactly for solving this kind of need.It is a feature-rich document list call tag that can help us flexibly extract and display various types of documents.One of its core advantages is the strong support for classification IDs, especially when dealing with 'multi-class' filtering, showing the elegance of its design.

The key to implementing the screening and display of documents based on multiple classification IDs isarchiveListlabel'scategoryIdthe parameters. You no longer need to write one for each classificationarchiveListCall, but you can also pass multiple category IDs separated by commas to this parameter.

For example, assume that your 'Latest News' category ID is5,“Hot Products” category ID is12,and the “Technical Tutorial” category ID is8。If you wish to display the latest documents of these three categories in the same area, yourarchiveListHow to label it:

{% archiveList archives with categoryId="5,12,8" type="list" limit="10" order="id desc" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            <p>{{item.Description|truncatechars:80}}</p>
            <span>发布于:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
        </a>
    </li>
    {% empty %}
    <li>当前暂无符合条件的文档。</li>
    {% endfor %}
{% endarchiveList %}

In this code block,categoryId="5,12,8"Command to query documents under categories with IDs 5, 12, or 8 in AnQiCMS.type="list"Means we do not need pagination,limit="10"It limited to display only the latest 10 documents, andorder="id desc"Ensured that the documents are sorted in descending order by document ID, usually representing the most recently published content.forThe loop is used to iterate through these filtered documents, displaying their titles, descriptions, and publication dates one by one. If no documents meet the criteria,emptyBlock hints will appear, providing users with friendly feedback.

Combined with other parameters, create a more accurate content presentation.

archiveListThe power of the tag is not just limited to this. When you need to control the display content more finely, you cancategoryIdcombine the parameters with other parameters to achieve more accurate filtering and sorting.

  1. Specify content model (moduleId): AnQiCMS supports custom content models. If you have a "article model" (ID may be 1) and a "product model" (ID may be 2), and you want to display only articles under specific categories and not products, you cancategoryIdincreased on the basis ofmoduleIdParameter.{% archiveList archives with moduleId="1" categoryId="5,8" type="list" limit="10" %}This will only filter documents from the categories with IDs 5 and 8 in the article model.

  2. excluding specific categories(excludeCategoryId): Sometimes you may want to display all documents under a specific content model but exclude a few unrelated categories.excludeCategoryIdParameters can help you achieve this.{% archiveList archives with moduleId="1" excludeCategoryId="6,9" type="list" limit="15" %}This command will list the latest 15 articles from all article models, excluding categories with IDs 6 and 9.

  3. Multiple sorting (order): In addition to sorting by ID (i.e., publication time), you can also sort by document views (views desc), and custom sorting in the background (sort descSort in this way. Combining multi-class filtering can help you find the most popular or most relevant documents across multiple categories.{% archiveList archives with categoryId="5,12,8" type="list" limit="10" order="views desc" %}This will display the top 10 documents with the highest views from these three categories.

  4. Recommended attribute filtering (flag): AnQiCMS provides various recommended attributes for documents, such as "Headline[h]", "Recommended[c]", "Slideshow[f]", etc. If you want to filter documents marked as "Recommended" across multiple categories, you can useflagParameter.{% archiveList archives with categoryId="5,12,8" type="list" limit="5" flag="c" %}This will select 5 documents marked as 'recommended' from these three categories.

Through the flexible combination of these parameters,archiveListTags can help you build highly customized content display modules, whether it's news aggregation, product lists, or special topic recommendations, they can easily handle them, greatly improving the efficiency of content operations and the attractiveness of website content.

Tips for operation: Rational planning of category ID and content model

To give full play toarchiveListThe powerful function of tags, the content planning in the early stage is crucial.

  • Clear classification systemIn the background, establish a clear and logical classification structure, assign clear responsibilities to each category, which is helpful for you to quickly and accurately locate content when usingcategoryIdparameters.
  • A unified content modelFor the same type of content, try to use the same content model. This allows you tomoduleIdexercise overall control and manage the categories under it uniformly when necessary.
  • utilize recommended attributesTake full advantage of the documentation'sflagProperties, marking documents that are important, recommended, or have special display requirements can achieve more flexible filtering.

In short,archiveListThe combination of tags with multiple category IDs is a great tool for AnQiCMS content operation.Master its usage and combine it with actual operational needs for parameter configuration, and you will be able to manage and present website content more efficiently and accurately.


Frequently Asked Questions (FAQ)

Q1: Can I usecategoryIdAre the parameters filtering from differentmoduleIdmultiple categories?

A1: No,categoryIdThe parameters are based on a singlemoduleId. This means you cannot be in the samearchiveListSpecify at the same time in the tagmoduleId="1"And the classification ID of the articlemoduleId="2"And the classification ID of the product. If you need to display multiple classification documents from different content models, you should provide eachmoduleIdUse onearchiveListtag to retrieve data, then combine or display them in blocks according to design requirements.

Q2: If I setcategoryIdHow to filter multiple categories, what is the sorting logic of the documents? For example, I have setcategoryId="5,8"and sort byid descSort, AnQiCMS first finds the latest document in categories 5 and 8 and merges them, or sorts globally among all documents that meet the conditions?

A2: AnQiCMS will internally match all that meet the criteriacategoryIdThe document with condition (i.e., ID 5 or 8) as a whole dataset, then sort this complete dataset according to the specified parameter (orderThis means that if you setorder="id desc"It will return all documents from categories 5 and 8, sorted by publication date, without being followed by the "latest document of category 5" and then the "latest document of category 8".This is a global sorting that ensures the unity of the results.

Q3: I found that some documents belong to multiple categories, when I usecategoryIdparameter filtering for one category, will these documents be recalculated or displayed repeatedly?

A3: In most modern CMSs, including AnQiCMS, documents are usually designed to belong to one or more categories. When you usecategoryId="ID1,ID2"When filtering, the system will query all documents that belong to ID1 or ID2 at least.However, the final document list will be deduplicated to ensure that each document appears only once in the results.archiveListIt appears once in the result, and will not cause duplicate display.