archiveListThese two powerful functions of tags.
Secure CMSarchiveList深度解析:精准获取文档与灵活分类控制
In the Anqi CMS,archiveListThe tag is undoubtedly the core of content display.It acts as a powerful filter, helping us extract documents that meet specific conditions from a massive amount of content (including articles, products, etc.), and presents them in various forms on the website front-end.archiveList都扮演着不可或缺的角色。它沿用了Django模板引擎的简洁语法,通过{% tag %}来定义标签,{{ variable }}Output variables to make template development intuitive and efficient.
By default, we may simply callarchiveListto retrieve the latest document list under a certain model:
{% archiveList archives with moduleId="1" type="list" limit="5" %}
{% for item in archives %}
<li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% empty %}
<li>暂无文档。</li>
{% endfor %}
{% endarchiveList %}
However, the powerful aspects of Anqi CMS are not limited to this. When we need to control the source of content more finely,userIdandchildthese two parameters can exert their unique functions.
一、English Content Publisher:userIdThe clever use of parameters
In a multi-user or multi-author collaborative website environment, such as a blog written by multiple experts or a platform showcasing the works of different creators, we may need to list all the documents published by a specific author separately.archiveListofuserIdThe parameter comes into play.
userIdThe parameter allows us to specify a user ID,archiveListIt will only return all documents published under the specified user ID.This is extremely useful for building personal author columns, showcasing selected content by editors, or conveniently viewing the content that users have published.User ID is typically the unique identifier assigned to each administrator or content publisher by the security CMS backend.
Imagine, in a blog named “Technology Exploration”, the user ID is1The author is “Dr. Zhang”, the user ID is2The author is “Li Engineer”. If we want to display all the articles of “Zhang Doctor” on a specific page, we just need to use it like this.userIdParameters:
{% archiveList archives with userId="1" moduleId="1" type="list" limit="5" %}
{% for item in archives %}
<li>【作者 ID: {{ item.UserId }}】<a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% empty %}
<li>该作者暂无文档发布。</li>
{% endfor %}
{% endarchiveList %}
Through this method, we can easily create a personal homepage for each author, dynamically displaying their portfolio, greatly enhancing the organization and personalization of content.This also helps build the personal brand of the author and enhance users' sense of belonging and stickiness in terms of operational strategy.
II. Focused Classification:childThe Magic of Parameters
The content classification system of AnQi CMS usually supports multi-level structures, such as "News Center" may have sub-categories such as "Company NewsarchiveListLabel's default behavior (auto)childThe parameter defaults totrue)。However, sometimes our operational goal is to make users focus only on the content of the current parent category itself, while ignoring the documents of its subcategories, in order to achieve a more precise thematic focus.
This is,childParameters are particularly crucial. When we usechildparameter settingsfalsewhenarchiveListOnly the specifiedcategoryIddocuments under it will be included, and not any documents in its subcategories.
For example, if the "News Center"categoryIdYes10,“Company News” is10The subcategory, if we want to display only the documents directly published to the 'News Center' category on the 'News Center' page, and not show any documents from the 'Company News' or other subcategories, we can configure it like thisarchiveList:
auto