AnQiCMS as an efficient and flexible content management system provides a variety of content display methods, among which the presentation of the document list is a very core part of website operation.Whether it is the homepage of the website, the category page, or the topic aggregation page, we hope to dynamically display the latest articles, the most popular content, or carefully recommended high-quality documents according to different operational goals.All this can be done through the powerful AnQiCMSarchiveListLabel it easily.
archiveListThe tag is the core tool we use in the AnQiCMS template to retrieve and display document lists.It allows us to precisely control which documents to display, how to sort them, and how many to show.Let's explore how to cleverly use this tag to create a document list that meets various needs.
Flexible call: Basic document list display
While usingarchiveListWhen labeling, it is usually structured in such a way:
{% archiveList archives with type="list" limit="10" %}
{% for item in archives %}
<li>
<a href="{{item.Link}}">{{item.Title}}</a>
{# 更多文档字段如 item.Description, item.CreatedTime, item.Views 等可以在这里展示 #}
</li>
{% empty %}
<li>暂时没有找到相关内容。</li>
{% endfor %}
{% endarchiveList %}
here,archivesIt is a custom variable name used to store the list of documents obtained.type="list"It means we want to get a simple list, andlimit="10"It limited to display only the latest 10 documents. When the list is empty,{% empty %}the content in the block will be displayed as a friendly reminder to the user.
Display the latest documents: Keep information always fresh
Users always crave for the latest information. Displaying the latest articles on blogs, news, or industry information sites is an important strategy to attract users and maintain activity. WitharchiveListWe just need to adjustorderthe parameters, we can easily implement the 'Latest Documents' list.
To sort by publication time in descending order, that is, the latest documents are listed first, we can setorder="id desc". Here,idIt usually represents the unique identifier of a document, and the higher the value, the later the document was published.
{# 显示最新的5篇文章 #}
{% archiveList latestArticles with order="id desc" limit="5" %}
{% for item in latestArticles %}
<div class="article-card">
<h4><a href="{{item.Link}}">{{item.Title}}</a></h4>
<p>发布时间:{{stampToDate(item.CreatedTime, "2006-01-02")}}</p>
</div>
{% endfor %}
{% endarchiveList %}
By this code, the website will dynamically pull the latest five articles released in the system, and sort them in chronological order to ensure that visitors see the latest content first.
Display the hottest documents: Insight into user interest focus
The "hot document" often represents the content that the current user is most interested in and the most frequently discussed.It can help new users quickly understand the popular trends of the website and also inspire the enthusiasm of old users.In AnQiCMS, the document's 'views' are an important indicator of its popularity.Therefore, we can go throughorder="views desc"Come and get the hottest documents.
{# 显示浏览量最高的8篇文档 #}
{% archiveList hottestArticles with order="views desc" limit="8" %}
{% for item in hottestArticles %}
<div class="popular-item">
<a href="{{item.Link}}">{{item.Title}}</a>
<span>({{item.Views}}次阅读)</span>
</div>
{% endfor %}
{% endarchiveList %}
This way, your website can intelligently display the articles with the highest views and popularity, allowing users to see at a glance what everyone is paying attention to.
Recommended: Use recommendation attributes to promote accurately
In addition to the latest and the most popular, we often need to manually tag some "excellent recommendations", "headlines", "slides", and other documents according to operational strategies to highlight their importance.AnQiCMS provides a flexible "recommended attribute" feature in the background, allowing us to set different tags for documents (such as "headline[h]", "recommended[c]", "slide[f]", "special recommendation[a]", "scroll[s]", "image[p]", "jump[j]", etc.).
InarchiveListIn tags, we can pass throughflagParameters to specify the recommendation attributes to be filtered. Please note,archiveListTags can only filter one at a time in a single callflagProperty.
For example, if you want to display the document marked as "slide[f]" on the homepage, you can set it up like this:
{# 显示标记为“幻灯”的3篇文档作为轮播图 #}
{% archiveList slideDocs with flag="f" limit="3" %}
{% for item in slideDocs %}
<div class="swiper-slide">
<img src="{{item.Logo}}" alt="{{item.Title}}">
<h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
</div>
{% endfor %}
{% endarchiveList %}
If you want to display the document marked as "recommended[c]" in the sidebar:
{# 显示标记为“推荐”的6篇文档 #}
{% archiveList recommendedArticles with flag="c" limit="6" %}
<ul class="sidebar-recommend">
{% for item in recommendedArticles %}
<li><a href="{{item.Link}}">{{item.Title}}</a></li>
{% endfor %}
</ul>
{% endarchiveList %}
In this way, you can display different types of selected content in different areas of the website based on specific attributes set for the document in the background, greatly enhancing the flexibility of content operations.
Advanced Applications and Precautions
archiveListThe power of tags goes beyond this, as they also support more parameter combinations to meet more complex display needs:
- Specify the category: Use.
categoryIdThe parameter can limit the document to come only from a specific category. For example,categoryId="1"Only the ID of