How to implement descending order by publish time, view count, or update time in the AnQiCMS document list?

Calendar 81

In website operation, how to efficiently present content lists so that users can quickly find the information they are most interested in or most valuable is an important issue.AnQiCMS provides flexible document list functionality, allowing us to easily implement content list sorting in descending order based on various conditions such as publish time, views, or update time.This not only optimizes the user experience, but also helps improve the exposure and interactivity of the content.

The core of document list sorting in AnQi CMS:archive/listInterface

AnQi CMS's document list function is mainly through:/api/archive/listImplement through an interface.This interface is very powerful, it allows us to retrieve various customized document lists by passing different parameters.orderParameter.

orderThe parameter accepts a string to specify the sorting field and direction. To achieve descending order, that is, to have the latest, most popular, or most recently updated documents at the top, we just need to add after the sorting fielddesc(means descending, in descending order) is enough.

Next, let's see how to set this according to different needs.orderParameter.

Sort by publication time in descending order (latest first).

If you want the user to see the most recently published content when they open a website or a certain category, then sorting by publication time in descending order is **the choice. In AnQi CMS, the publication time of the document corresponds tocreated_timeField. This field stores the timestamp of document creation. To prioritize the display of the most recently published documents, simply set the/api/archive/listparameter to:orderset the parameter to:

order=created_time desc

This system will sort documents from new to old based on the publication time, ensuring that the latest articles, products, or other types of content are displayed to users first.

Sort by view count in descending order (popular content first)

The user's attention to the content is often reflected directly through the number of views.If your goal is to highlight the most popular and most viewed articles or products, creating a "Hot List" or a "What Everyone's Watching" section, then sorting in descending order of views is very suitable.viewsfield, which records the number of views for each document. To sort by view count from high to low, you can set it in theorderparameter as follows:

order=views desc

After configuration, documents with higher page views will be displayed higher in the list, which helps guide new users to discover high-quality or popular content.

Sort by update time in descending order (latest revision first)

For some documents that require continuous updates and have strong timeliness, such as technical tutorials, regulations interpretation, or product descriptions, users may be more concerned about the latest revision status of the documents.At this moment, sorting by update time in descending order allows users to quickly obtain the latest information.updated_timefield records the timestamp of the last modification of the document. To sort by update time from new to old, you should setorderset the parameter to:

order=updated_time desc

In this way, even if the document has been published for a long time, as long as its content is updated, it can regain exposure opportunities and ensure that users can always access the latest version of the information.

Application in practice

In practical website development, front-end developers or template creators will call/api/archive/listthe interface, flexibly combine these sorting parameters and other filtering conditions such asmoduleId/categoryId/limit/pageand). For example, on a news center page, you may need to retrieve the article model (moduleId=1) under a certain category (categoryId=5The latest list of released articles, and 10 per page, the combination of request parameters may be:

/api/archive/list?moduleId=1&categoryId=5&order=created_time desc&type=page&page=1&limit=10

With such a combination, Anqi CMS can help us build a highly customized and user-friendly content display form, making website content management more convenient.


Frequently Asked Questions (FAQ)

Q1: Can multiple sorting conditions be used at the same time? For example, sort by publication time in descending order first, and then by views in descending order?A: According to the documentation of Anqi CMS, orderThe parameter currently supports specifying a sorting field and direction.If you need to implement more complex composite sorting logic (for example, to sort by views when the publishing time is the same), you may need to perform secondary sorting processing in your code after obtaining the data on the front end.It is recommended that you consult the technical support of Anqi CMS first when you have this need, to see if there are more advanced backend sorting rules or future support plans.

Q2: How to achieve ascending order in addition to descending order?A: If you want the content list to be displayed in order from small to large (or from old to new) based on time, views, etc., just need to adjust theorderIn the parametersdescchanged toasc(which means ascending, in ascending order) is enough. For example,order=created_time ascIt will place the oldest documents first.

Q3: What if the field I want to sort by is notid/views/created_time/updated_timein?A: Safe CMS ofarchive/listinterface inorderThe parameter description explicitly lists the supported sorting fields.If you want to sort by a custom field, make sure that custom field has been configured as sortable by the system.orderParameter sorting. The most direct way to handle custom fields not listed is to sort the document list data in the front-end code after obtaining it.

Related articles

How to precisely control the number of documents returned and the starting offset of AnQiCMS document list (advanced usage of `limit` parameter)?

When building and managing website content, AnQiCMS provides a series of flexible API interfaces to help us accurately obtain and display data.Among them, the `archive/list` interface is the core for obtaining the document list, and its `limit` parameter demonstrates its powerful fine-grained control capabilities in terms of controlling the number of returned items and the starting offset.Understand and master the advanced usage of the `limit` parameter, which can make our website content display more flexible and efficient.### `limit` parameter basic usage

2025-11-09

What is the main difference between the `type="page"` and `type="list"` modes in the AnQiCMS document list interface?

When you are using AnQiCMS to build a website and need to retrieve document content from the backend, you will often encounter the document list interface (/api/archive/list).This interface provides a very important `type` parameter, which determines how you will obtain and process the document list data.A deep understanding of the core differences between the `type="page"` and `type="list"` modes is crucial for improving website performance, optimizing user experience, and developing more flexible features.###

2025-11-09

How to get the latest document list of the specified model (`moduleId`) through AnQiCMS?

In website content management, we often need to dynamically display the latest updates of a certain type of content, such as news articles, product releases, or blog updates.For websites built using AnQiCMS, leveraging its powerful API interface to obtain the latest document list under a specified model is a very basic and practical operation.This can not only help developers build dynamic pages quickly, but also provide users with timely updated information, optimizing the user experience of the website.To implement this feature, we mainly use the AnQiCMS provided

2025-11-09

How to dynamically build a frontend filtering UI based on the response of `archiveFilters`, such as dropdown menus or checkboxes?

In today's increasingly rich content of websites, how to allow users to quickly find the information they are interested in is a crucial operational issue.AnQiCMS provides powerful content management capabilities, and its API interface provides a solid foundation for front-end developers to build flexible and varied interactive interfaces.Today, let's delve into how to use the response data from the `archiveFilters` interface to dynamically build front-end filtering UI, such as common dropdown menus or checkboxes.The value of dynamic filtering interface Imagine that

2025-11-09

How to filter the AnQiCMS document list to display articles under a specific category (`categoryId`)?

How to accurately filter out articles under specific categories when managing and displaying a large amount of content in Anqi CMS is a key link to improve the organization of website content and user experience.Strong and flexible interfaces are provided by AnQi CMS, allowing us to easily achieve this goal.This article will provide a detailed introduction on how to use the document list interface of Anqi CMS to only display specific categorized articles that you hope to see.### Master the document list interface: the core of content filtering To filter articles under specific categories, we need to use the `/api/archive/list` interface provided by AnQi CMS

2025-11-09

Does the AnQiCMS document list interface support excluding multiple categories of documents at the same time (`excludeCategoryId` usage)?

In website operation, we often need to flexibly display content, such as displaying the latest articles on a page, but not including content under certain specific categories, such as announcements or internal news.AnQiCMS as a powerful content management system, provides a rich set of API interfaces to meet these complex display requirements.Today, let's delve into a very practical parameter of the `archive/list` interface: `excludeCategoryId`, especially how it supports excluding multiple categories of documents.###

2025-11-09

How to get the document list with 'Headline' or 'Slide' recommended attributes (`flag`) in AnQiCMS?

In AnQiCMS (AnQiCMS), content managers often need to flexibly display important content on the website, such as setting specific articles as 'headline' or 'slideshow' to attract users' attention.The AnQi CMS provides a very practical feature, that is, marking documents through the 'recommended attribute' (flag).If you want to get the list of documents marked specially, the AnQiCMS API interface can help you achieve it easily.

2025-11-09

How does the `child=false` parameter affect the display of categories and their subcategories when retrieving the document list?

In Anqi CMS, the `archive/list` interface is the core tool for obtaining the list of website documents, which provides a variety of parameters to help us accurately filter and display content.Among them, the `child` parameter, although simple in appearance, plays a vital role in the display of categories and their subcategories in documents, directly affecting the granularity of content presentation.Understand and make good use of this parameter, it can make the content organization of your website clearer and improve the user experience.By default, when you access `archive/list`

2025-11-09