How to sort the document list by publication time or views?

Calendar 👁️ 66

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:cooperatecategoryIdormoduleIdFilter 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.

Related articles

How to filter and display the document list based on recommended properties (Flag)?

As an experienced website operations expert, I know that the powerful function of the Content Management System (CMS) lies in its flexibility and ease of use.In AnQiCMS (AnQiCMS), the 'recommended attribute' (Flag) of the document is such a seemingly simple feature, which can actually greatly improve the efficiency of content operation and the diversity of website display.Today, let's delve into how to cleverly use recommendation attributes to achieve precise filtering and display of document lists.

2025-11-06

How to implement pagination and page number display for article lists in AnQi CMS?

As an experienced website operations expert, I am well aware of the crucial role of a powerful and easy-to-use content management system for the success of a website.AnQiCMS (AnQiCMS) boasts a high-performance architecture based on the Go language and flexible template mechanism, providing an excellent experience in content publishing and management.Among them, efficiently displaying a large amount of content, especially implementing the pagination function of the article list, is an indispensable factor in improving user experience and website SEO performance.Today, let's delve deeply into how AnQi CMS cleverly implements this feature and demonstrates friendly page navigation.--- ##

2025-11-06

How to get the list of articles under a specified category in AnQiCMS?

## Easily retrieve the list of articles under a specified category in AnQiCMS As an experienced website operations expert, I fully understand the core value of a content management system (CMS) lies in its ability to organize and present content.Among many features, how to efficiently extract and display articles from a specific category is an indispensable part of the daily work of website operators.Today, let's delve deep into how AnQiCMS can help you achieve this goal, making technical details intuitive and easy to understand.

2025-11-06

Unveiling AnQi CMS: How Markdown content is beautifully presented on your website?

AnQi CMS is an efficient content management system that knows well the pursuit of convenience by content creators.Markdown is a lightweight markup language that is favored by content editors for its concise, easy-to-learn, and clear formatting features.How can we ensure that the wonderful content you write in Markdown in Anqi CMS can be perfectly converted into browser-readable HTML and displayed on the front-end page without any loss?

2025-11-06

How to exclude certain specific categories of articles from the AnQiCMS document list?

During the operation of the website, we often need to manage and display content in a fine-grained manner.For example, we may wish to hide certain internal announcements, specific promotional content, or some draft category articles that are not suitable for external display when recommending articles on the homepage.AnQiCMS (AnQiCMS) is a powerful content management system that fully considers such needs and provides a simple and flexible way to achieve this - by specifying exclusion parameters in the document list tag.This article will delve into how to exclude certain categories of articles from the document list in AnQiCMS

2025-11-06

How to implement the 'related articles' recommendation feature in AnQiCMS?

As an experienced website operations expert, I am well aware of the importance of the 'related articles' recommendation feature for improving user experience, extending user stay time, reducing bounce rate, and optimizing the internal link structure of the website (SEO).AnQiCMS (AnQiCMS) provides a flexible and efficient solution in this regard, allowing website operators to easily implement intelligent content recommendations.

2025-11-06

How to perform keyword search on the AnQiCMS document list page?

Good, as an experienced website operations expert, I am happy to write a practical guide for you on how to perform keyword search in the AnQiCMS document list page. --- ## Efficient Keyword Search on AnQiCMS Document List Page: A Practical Guide Quickly locating and managing a large number of documents is crucial for improving efficiency in daily content operations.With the continuous enrichment of website content, we often need to accurately retrieve specific articles or products from the vast sea of information.

2025-11-06

How to implement custom parameter filtering for document lists in AnQiCMS (such as by region, type)?

## Unlock content potential: How AnQiCMS implements custom parameter filtering of document lists (such as by region, type) As an experienced website operations expert, I am well aware of the importance of an efficient content management system (CMS) in enhancing user experience and content value.AnQiCMS with its flexible and customizable features provides many conveniences in the content operation field.

2025-11-06