How to sort the list display according to the creation time or view count of the articles?

Calendar 👁️ 76

In website content operation, the presentation order of content is crucial for user experience and information communication efficiency.Whether it is a news portal, a technology blog, or a product showcase website, adjusting the sorting method of the content list reasonably according to different operational objectives can significantly enhance the vitality and attractiveness of the website.AnQiCMS (AnQiCMS) is well-versed in this, providing intuitive and powerful features that allow us to easily sort the content list by article creation time or page views.

Flexible and diverse list sorting mechanism

AnQi CMS through its corearchiveListThe tag provides great flexibility for displaying content lists. This tag allows us to filter and sort content based on various conditions, among whichorderThe parameter is the key to controlling the list sorting. By reasonable configurationorderThe parameter, we can give priority to the latest released content, or let the most popular articles stand out.

In AnQi CMS,orderParameters support the following main sorting rules:

  • id desc: Sort by content ID in descending order, which usually means that the most recently created or published content will be at the top.
  • views desc: Sort the content by views in descending order so that the content with the highest views is displayed first.
  • sort desc: Sort in reverse order based on the custom sorting weight of the background, which is usually used for the recommendation priority of content with manual intervention.

Next, we will focus on how to utilizeid descandviews descTo implement sorting by creation time or views.

Sort by creation time: to access fresh content.

For news, blogs, or any content that emphasizes timeliness, sorting by creation time in reverse order is the most common requirement. In Anqi CMS,idThe field is usually closely associated with the order of content creation, therefore, byorder="id desc"Parameters, we can conveniently implement the effect of "latest release". If you need to sort in chronological order (for example, to display content released early), you can useorder="id asc".

For example, on your website's homepage or in the "Latest Articles" block of a specific category page, you can display the five most recently published articles using the following code snippet:

<h4>最新文章</h4>
<ul>
{% archiveList latestArticles with type="list" limit="5" order="id desc" %}
    {% for article in latestArticles %}
    <li>
        <a href="{{ article.Link }}">{{ article.Title }}</a>
        <span class="publish-time">{{ stampToDate(article.CreatedTime, "2006-01-02") }}</span>
    </li>
    {% empty %}
    <li>暂无最新文章。</li>
    {% endfor %}
{% endarchiveList %}
</ul>

In this code,order="id desc"Ensure that the content is arranged in chronological order (the most recent first).stampToDateThe filter then captures the creation time of the article (CreatedTimeField, a timestamp formatted into a readable date format, enhancing user experience.

Sorted by views: focuses on hot content, guiding traffic.

The website is operating, prioritizing popular or highly viewed content to effectively attract users' attention and guide them to discover more hot information. Anqi CMS'sviewsThe field directly records the number of page views of the article, therefore, usingorder="views desc"the parameter, you can easily implement the 'Hot Articles' or 'You May Also Like' function.

Assume you want to recommend five of the most popular articles at the bottom of the sidebar or article, you can set it like this:

<h4>热门文章推荐</h4>
<ul>
{% archiveList popularArticles with type="list" limit="5" order="views desc" %}
    {% for article in popularArticles %}
    <li>
        <a href="{{ article.Link }}">{{ article.Title }}</a>
        <span class="views-count">({{ article.Views }} 次浏览)</span>
    </li>
    {% empty %}
    <li>暂无热门文章。</li>
    {% endfor %}
{% endarchiveList %}
</ul>

Byorder="views desc"The system will intelligently filter out the articles with the highest views, and sort them in descending order to ensure that the most popular content is presented to users first.

Actual application scenarios and operational considerations

These two sorting methods provided by Anqi CMS are widely used in actual operation:

  • Homepage and news dynamic: Usually adopts reverse chronological order based on creation time (order="id desc"Make sure users see the latest information first.
  • Hot recommendations or rankingsUse the descending order of views(order="views desc")Highlight the star content of the website to attract clicks.
  • Content Aggregation PageFor example, a specific topic aggregation page can display the latest related articles at the top, and popular articles under the topic can be displayed below, or combinedcategoryIdParameters are limited to sorting within specific categories.
  • Product listCan display new products by release time, or recommend best-selling products by views.
  • Manual intervention:In addition to automated sorting, when there are important promotions or special events, you can use custom sorting weights set through the backend (order="sort desc"Adjust the priority of content manually to achieve more refined operation.

The flexible sorting function of AnQi CMS allows content operators to freely combine and switch the display methods of content lists according to the overall strategy of the website, user behavior habits, and specific page operation objectives.This not only optimizes the user's information acquisition path, but also improves the overall content value of the website.

Frequently Asked Questions (FAQ)

Q1: Besides sorting by publish time and view count, what other sorting methods does Anqi CMS support?A: Besides sorting by publish time (id descorid asc) and views (views desc), Anqi CMS also supports custom sorting weights set in the background (order="sort desc"This option allows operators to manually adjust the importance of the article to prioritize it in the list.

Q2: Do I want to display multiple content lists on the same page, such as 'Latest Articles' and 'Popular Articles', can this be achieved?A: Absolutely. You just need to use two separatearchiveListtags, and configure them with differentorderparameters (for example, oneorder="id desc", and the otherorder="views desc") as well as appropriatelimitParameters, so you can display different sorted content lists on the same page.

Q3: If I only want to display the latest or most popular articles under a specific category, how can I operate?A: You canarchiveListin the tag, besidesorderusing parameters at the same timecategoryIdSpecify the category of the content. For example, to display the latest 5 articles with category ID 1, you can write it like this:{% archiveList articles with categoryId="1" limit="5" order="id desc" %}.

Related articles

How to implement the pagination display function of the article list in AnQiCMS?

The pagination feature of the article list is crucial for any content management system, as it not only improves the user browsing experience and avoids the slow loading caused by overly long single pages, but also helps search engines better crawl and index website content.In AnQiCMS, implementing this feature is both flexible and efficient, thanks to its concise template tag design. Next, we will together learn how to easily implement pagination display of article lists in AnQiCMS.

2025-11-08

How to display the viewing volume of articles or products on the frontend page?

Bring content to life: easily display the number of views for articles or products on the Anqi CMS front-end page In website operations, the number of views for articles or products is often an important indicator of how popular the content is.It not only provides visitors with an intuitive reference, forming a "social identity" effect, guiding them to discover popular content, but also helps operators quickly identify high-value content.AnQi CMS is an efficient content management system that fully considers the actual needs of users, making it very simple and intuitive to display the number of views of articles or products on the front-end page.

2025-11-08

How to set a default thumbnail to automatically display when there is no image in the article?

In content operation, images play a crucial role.They can not only catch the visitor's eye, enhance reading interest, but also effectively convey information and enhance the brand image.However, when updating articles daily, we may occasionally forget to upload thumbnails, or some content is not suitable for pictures.This is when a blank page appears on the article list or detail page, which seems unprofessional and affects user experience.Fortunately, AnQiCMS (AnQiCMS) has considered this point and provided a very practical feature: setting a default thumbnail.With it, even if the article does not have a picture

2025-11-08

What thumbnail processing methods does AnQiCMS support, and how to set them to optimize the display effect?

In website operation, image content plays a crucial role, especially exquisite thumbnails can quickly attract users' attention, enhance the visual beauty of the page, and improve the click-through rate.AnQiCMS (AnQiCMS) offers flexible and diverse functions in image processing, especially for thumbnail generation and optimization, aiming to help websites achieve **display effects.We will delve into the thumbnail processing methods supported by AnQiCMS, as well as how to make your website images come to life through reasonable settings.### The core mechanism of AnQiCMS thumbnail processing First

2025-11-08

How to display 'Previous article' and 'Next article' links on the article detail page?

In website content operation, optimizing the reading experience of users has always been one of our core goals.When immersed in an excellent article, it is natural to want to smoothly switch to related or the next article without having to return to the list page to find it.This seamless navigation can not only effectively improve the user's stay time on the website, reduce the bounce rate, but also help search engines better understand the structure of the website content, thereby having a positive impact on SEO.Aqy CMS provides a very intuitive and easy-to-use solution for this

2025-11-08

How to create and display multi-level navigation menus in AnQiCMS?

In website operation, a clear and effective navigation menu is the core of user experience, which can help visitors quickly find the information they need.AnQiCMS (AnQiCMS) knows this well and provides flexible and powerful features for you to easily create and manage multi-level navigation menus, whether it is a simple two-level dropdown menu or a complex menu combined with dynamic content display, it can meet your needs. Next, we will learn together how to create and display multi-level navigation menus in AnQiCMS.### One, Back-end Management

2025-11-08

How to highlight the link of the current visited page in the navigation menu?

When a user visits your website, a clear and intuitive navigation menu can significantly enhance their browsing experience.One important optimization is to make the navigation menu intelligently highlight the current page link being visited, so that visitors can clearly know where they are on the website.AnQi CMS provides a simple and powerful way to implement this feature, without complex development, just need to configure cleverly in the template.### Understanding the navigation mechanism of Anqi CMS Anqi CMS is built with a flexible template tag system, the core of which is the "navigation list tag"

2025-11-08

How to set and display the common areas of the website such as header, footer, and sidebar in AnQiCMS?

In website operation, the header, footer, and sidebar, etc., play a crucial role.They not only carry the brand image and navigation function, but also the key to improving user experience and content distribution efficiency.For those who use AnQiCMS, understanding how to efficiently set up and display these areas will greatly enhance the professionalism and operational convenience of the website.AnQiCMS as an enterprise-level content management system based on the Go language, has fully considered the flexibility and scalability of templates from the very beginning.This means, whether it is to build a simple corporate website

2025-11-08