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.