In AnQiCMS, flexibly displaying content is one of the keys to building an efficient website.archiveListIt is such a powerful tool that allows us to filter and display the document list of the website according to various conditions. Whether you want to display a certain type of article on a specific page or organize information based on content type or editor's recommendation,archiveListProvide precise control.
Accurate positioning: Filter document list according to category ID.
When we want to display documents under a specific category in a certain area of the website, such as the sidebar or a special topic page,categoryIdThe parameter is put to good use. This parameter allows us to specify one or more category IDs, thus accurately extracting all documents under these categories.
For example, if you want to display the articles under the "Company News" category with ID 1, you can use it like this:
{% archiveList archives with categoryId="1" limit="5" %}
{# 在这里循环展示文档 #}
{% endarchiveList %}
If your content spans multiple categories, for example, if you want to display documents under both 'Company News' (ID 1) and 'Industry News' (ID 3), just separate these IDs with a comma:
{% archiveList archives with categoryId="1,3" limit="10" %}
{# 结合多个分类ID展示文档 #}
{% endarchiveList %}
It is worth noting that the AnQiCMS category can have a hierarchical relationship. By default, when you specify a parent category ID,archiveListIt will automatically include all documents under its subcategories. But if you only want to display the documents of the current specified category (excluding its subcategories), you can by settingchildthe parameter tofalseto achieve:
{% archiveList archives with categoryId="1" child=false limit="5" %}
{# 只展示ID为1分类下的文档,不包含其子分类 #}
{% endarchiveList %}
Moreover, in certain special page scenarios, we may wisharchiveListNot to automatically inherit the category ID of the current page, but to specify it manually. At this point, we cancategoryIdSet explicitly"0"Avoid any automatic inheritance behavior.
Content division: Filter document list according to model ID
The "Content Model" feature of AnQiCMS is a reflection of its high flexibility.It allows us to define different types of content structures, such as 'article model', 'product model', and even 'case model'.When we need to distinguish between different types of content and display it on the front end,moduleIdParameters are particularly important.
By specifyingmoduleIdWe can ensurearchiveListOnly extract documents that belong to a specific content model. For example, if the 'article model' ID is 1 and the 'product model' ID is 2, then we can do it like this:
Want to display the latest 5 articles:
{% archiveList articles with moduleId="1" order="id desc" limit="5" %}
{# 展示最新的5篇文章 #}
{% endarchiveList %}
If you want to list all the products:
{% archiveList products with moduleId="2" type="page" limit="10" %}
{# 列出所有产品,并支持分页 #}
{% endarchiveList %}
This model-based filtering method makes the website's content structure clearer, and it is also convenient for differentiated display and management for different content models.
Highlight the key points: Filter the document list based on recommended attributes
In addition to categories and models, AnQiCMS also provides a "recommendation attribute" feature that allows content operators to mark documents with special tags to achieve the effect of highlighting such as "headlines", "recommendations", and "slides."}flagParameters are used to take advantage of these recommendation attributes for filtering.
AnQiCMS supports various recommendation attributes, each with a corresponding letter identifier, such as:
h: Headlinesc: Recommendationsf: Slidesa: Special Recommendationss: Scrollp: Imagej: Jump
When you want to display documents marked as "slideshow" in the home page slideshow area, you can set it like thisflagparameters:
{% archiveList slides with flag="f" limit="3" %}
{# 展示3篇被标记为“幻灯”的文档 #}
{% endarchiveList %}
You can also filter out documents with multiple recommended properties, such as documents that are both 'recommended' and 'images', although usually only one main property is used:
{% archiveList featuredImages with flag="c,p" limit="4" %}
{# 展示4篇既是“推荐”又是“图片”的文档 #}
{% endarchiveList %}
withflagCorrespondinglyexcludeFlagIf you want to exclude documents with certain recommended properties, such as not displaying any "top" content, you can use it like this:
{% archiveList regularContent with excludeFlag="h" limit="10" %}
{# 展示除了“头条”之外的10篇文档 #}
{% endarchiveList %}
Combined use to achieve more refined filtering
archiveListThe strength of the tag lies in the fact that these filtering conditions are not mutually exclusive, but can be flexibly combined. By specifying at the same timecategoryId/moduleIdandflagWe can build a very specific list of documents.
For example, if you want to display the latest 10 documents under the "article model" with ID 1, category ID 5, and marked as "recommended", you can combine these parameters in this way:
{% archiveList targetedArticles with moduleId="1" categoryId="5" flag="c" order="id desc" limit="10" %}
{# 精准筛选:文章模型,分类ID为5,推荐属性,最新10篇 #}
{% endarchiveList %}
Moreover, for users who use the AnQiCMS multi-site management function, they can alsositeIdParameters to specify the document list under which site to retrieve, ensuring flexible content calls in multi-site environments.
Through the flexible use of these parameters,archiveListTags can help us accurately control the display of website content, whether it is to improve user experience or to optimize search engine rankings, it can provide strong support.
Frequently Asked Questions (FAQ)
1. I want to display the latest documents under a certain category on a page, and these documents must be of the "article model", how should I write it?
You can combinecategoryId/moduleIdandorderImplement the parameter. Assume the category ID is 5, and the article model ID is 1:
{% archiveList recentArticles with categoryId="5" moduleId="1" order="id desc" limit="5" %}
{# 在这里循环展示最新5篇“文章模型”下的分类5文档 #}
{% endarchiveList %}
2. How to avoidarchiveListIs it to automatically obtain the category ID of the current page, but to filter completely according to the ID I specify?
You cancategoryIdThe parameter is explicitly set to"0", like thisarchiveListIt will not attempt to read the category information of the current page, but will only use other filtering conditions you manually specify (or do not specify).
{% archiveList myCustomList with categoryId="0" moduleId="1" limit="10" %}
{# 确保不继承当前页面的分类ID,只展示模型ID为1的文档 #}
{% endarchiveList %}
3. Can I exclude all documents marked as 'Headline' from a list while also displaying content from a specific category?
Of course you can. You can use it at the same timecategoryIdandexcludeFlagParameter. Assuming the category ID is 10, the headline attributes to be excluded areh:
{% archiveList filteredList with categoryId="10" excludeFlag="h" limit="8" %}
{# 展示分类ID为10,且不是头条的8篇文档 #}
{% endarchiveList %}