AnQiCMS as an efficient and flexible content management system, provides a variety of content display methods, among which the presentation of document lists is a very core part of website operation.Whether it's the homepage, category page, or thematic aggregation page, we hope to dynamically display the latest articles, the most popular content, or carefully recommended high-quality documents based on different operational goals.archiveListLabel implementation is easy.
archiveListTags are the core tools we use to retrieve and display document lists in the AnQiCMS template.It allows us to precisely control which documents to display, in what order, and how many to show through a series of parameters.Let's explore how to cleverly use this tag to create document lists that meet various needs.
Flexible invocation: Display of basic document list.
When usingarchiveListWhen using labels, such a structure is usually adopted:
{% 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 variable name we define, used to store the obtained document list.type="list"indicates that we want to get a simple list,limit="10"It limits to display only the latest 10 documents. When the list is empty,{% empty %}the content in the block is displayed as a friendly reminder to the user.
Display the latest documents: keeping 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, and we can easily realize the "Latest Documents" list.
To sort by publish time in descending order, that is, the latest documents at the top, we can setorder="id desc"Here,idtypically represents the unique identifier of a document, and the higher the value, it usually means the document was published later.
{# 显示最新的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 %}
This code dynamically retrieves the five most recently published articles from the system and arranges them in chronological order, ensuring that visitors see the latest content first.
Present the most popular documents: Insight into user interest focus
The 'Hot Documents' often represent the content that the current users are most interested in and the most frequently discussed.It can help new users quickly understand the popular trends of the website and also stimulate the enthusiasm of old users.In AnQiCMS, the document's 'view count' is an important indicator of its popularity.order="views desc"Get the most popular 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 %}
So, your website can intelligently display the articles with the highest traffic and popularity, allowing users to easily see what everyone is paying attention to.
精选推荐:Utilize recommendation attributes for precise promotion
In addition to the latest and the most popular, we often need to manually tag some documents such as 'Featured Recommendations', 'Headlines', 'Slides' and others based on operational strategies to highlight their importance.AnQiCMS provides a flexible 'recommendation attribute' feature in the backend, allowing us to set different tags for documents (such as 'head[h]', 'recommended[c]', 'slideshow[f]', 'featured[a]', 'scrolling[s]', 'image[p]', 'jump[j]' and so on).
InarchiveListIn tags, we canflagSpecify the recommended attributes to be filtered. Please note,archiveListA tag can only filter one at a time in a single callflagproperties.
For example, if you want to display documents 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 documents 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 %}
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 backend, greatly enhancing the flexibility of content operations.
Advanced Application and Precautions
archiveListThe power of tags is not just this, it also supports more parameter combinations to meet more complex display requirements:
- Specify Category: Use
categoryIdThe parameter can limit the document to come only from specific categories. For example,categoryId="1"Only documents with ID