In the world of website operation, the organization and presentation of content directly affects user experience and the efficiency of information transmission.AnQiCMS (AnQiCMS) as an efficient content management system, fully understands the importance of this need, and therefore provides powerful and flexible options for the sorting function of the document list, allowing you to easily control the display priority of content according to different operation objectives.Today, let's delve into how to sort document lists in Anqi CMS using publish time or views.
The importance of content sorting: why should we pay attention to publish time and view count?
Imagine, a news site wants users to always see the latest headlines, while a product showcase page tends to highlight the most popular bestsellers.These scenarios cannot do without an effective sorting strategy.Publish time, representing the freshness and timeliness of the content, it is the preferred sorting basis for news, blogs, announcements, and other types of content.While the number of views directly reflects the popularity and user interest in the content, sorting by views for popular articles, recommended products, and high-value guides allows users to find resonance faster.The AnQi CMS precisely grasps these core needs and provides you with a simple and clear solution.
The secret weapon of AnQi CMS:archiveListThe powerful sorting ability of tags
In the template design of AnQi CMS,archiveListTagIt is the core tool for you to manage the document list. It not only helps you filter documents under specific categories and models, but also through itsorderParameter, implements various sorting logic. The system silently records itscreation time (CreatedTime)andviews (Views)Waiting for key data, which lays the foundation for subsequent sorting operations.
First, sort by publishing time: Let fresh content be within reach.
Let your users see the latest content first, and sorting in descending order by publication time is the most direct and effective way. AtarchiveList标签中,您可以通过设置order="id desc"To achieve this goal.In AnQi CMS, the document ID is usually auto-incremented, so sorting by ID in descending order is usually equivalent to sorting by publication time in descending order, because new documents often have larger IDs.
If you want to explicitly show the publication date of the document in the list, you can easily call it within the loopitem.CreatedTimefield, and combinestampToDateusing a filter to format the output, for example{{stampToDate(item.CreatedTime, "2006-01-02")}}It can convert timestamps into a readable date format.
{# 示例:展示最新发布的5篇文章 #}
{% archiveList latestArticles with type="list" limit="5" order="id desc" %}
{% for item in latestArticles %}
<li>
<a href="{{item.Link}}">{{item.Title}}</a>
<span>发布于:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
</li>
{% endfor %}
{% endarchiveList %}
With such configuration, no matter when a user visits your website, it can ensure that they see the latest content in the specified region.
Second, sort by views: highlight popular items to attract more attention
For those who want to attract users and increase website activity through popular content, sorting by views is undoubtedly your powerful assistant. You just need toarchiveListlabel'sorderthe parameter toorder="views desc",AnQi CMS will automatically display the document with the highest number of views on the website first.
Similarly, if you want to display the popularity of each article to the user intuitively, you can show it in the list itemitem.Viewsfield.
{# 示例:展示浏览量最高的5篇文章 #}
{% archiveList hotArticles with type="list" limit="5" order="views desc" %}
{% for item in hotArticles %}
<li>
<a href="{{item.Link}}">{{item.Title}}</a>
<span>浏览量:{{item.Views}}</span>
</li>
{% endfor %}
{% endarchiveList %}
This sorting method is particularly suitable for content blocks such as "Hot Recommendations" and "Weekly Selections", which can effectively guide users to discover the high-quality content on the website.
III. Flexible and diverse application scenarios
Of Security CMSarchiveListTags not only support single sorting, but can also be combined with other parameters to achieve fine-grained control in different content modules. You can flexibly apply these sorting strategies in all corners of the website according to your actual operational needs:
- Home news module:
order="id desc"(Sorted by latest release) - Sidebar popular articles:
order="views desc"(Sorted by views) - Special topic page:cooperate
categoryIdormoduleIdFilter specific content and then sort by publication time or views. - Custom sort:Besides the two common methods mentioned above,
archiveListit also supportsorder="sort desc"Allow you to manually adjust the document sorting weight in the background, achieving more personalized content presentation.
Summary
Anqi CMS through its intuitive and powerful interface.archiveListTags make sorting document lists unprecedentedly simple and flexible. Whether you're pursuing timeliness with "Latest Release" or emphasizing popularity with "Hot Articles", you can easily pass throughorderSet the parameters to ensure that your high-quality content is always presented in the most suitable manner for your operational goals.This fine control ability is exactly what Anqi CMS helps you efficiently operate the website and optimize the user experience.
Frequently Asked Questions (FAQ)
1. I set uporder="id desc"But why do I feel that the content publishing time is not always the most accurate and latest?Answer:id descIt is usually sorted in descending order by document ID, since IDs are usually incremental, this is equivalent to sorting by creation time (i.e., publish time) in most cases.However, if your website uses the "Scheduling Release" function of AnQi CMS, a document may have been created and assigned an ID early, but the actual release time is in the future.In this case, although the ID is earlier, the actual publishing time may be later than the document with the later ID.id descIt is a good approximation. If you need to display the exact publication time, make sure to call it in the template{{stampToDate(item.CreatedTime, "格式")}}.
2. Can I display a list sorted by publish time and a list sorted by views on the same page?Of course, you can. The template tags of Anqi CMS run independently. You can set different ones in different areas of the page or in differentarchiveListtag blocks separately.orderparameters. For example, you can display a "latest articles" list at the top of the website(order="id desc"), and also display a "popular articles" list in the sidebar(order="views desc"),Both are mutually independent, showing the required content separately.
3. In addition to the publish time and view count, what document list sorting methods does Anqi CMS support?Answer: In addition to sorting by publication time (usually throughid descimplementation) and view count (views desc), Anqicms also supportscustom sorting by backend (sort desc).This means you can manually set a sorting weight for each document in the Anqi CMS backend management interface, and the system will arrange according to these weights.This approach provides content managers with greater flexibility, allowing them to adjust the priority of content based on manual judgment, such as promoting important promotional content or featured articles to the top display.