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

Flexible and diverse list sorting mechanism

AnQi CMS through its corearchiveListTags, provide great flexibility for displaying content lists. This tag allows us to filter and sort content based on multiple conditions, whereorderThe parameter is the key to controlling the list sorting. By reasonable configurationorderWe can give priority to the latest released content or make the most popular articles stand out with the parameter.

In the Anqi CMS,orderThe parameter supports the following main sorting rules:

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

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

Sort by creation time: make fresh content accessible.

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 creation time of the content, therefore, byorder="id desc"Parameters, we can conveniently achieve the effect of "latest release". If you need to sort in ascending order by time (for example, to display content released early), you can useorder="id asc".

For example, on the homepage of your website or a specific category page, you can display the latest five 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 block,order="id desc"Ensured that the content is arranged in chronological order of publication (the latest at the top).stampToDateThe filter then applies to the creation time of the articles (CreatedTimeField, a timestamp) formatted into a date format that is easy for us to read, improving user experience.

Sorted by views: focuses on hot content, guides traffic

The website is in operation, and popular or high-traffic content is displayed first to effectively attract user attention and guide them to discover more hot information. The Anqi CMS isviewsThe field directly records the page views of the article, therefore, usingorder="views desc"the parameter, you can easily realize the function of "Hot Articles" or "You May Also Like".

If you want to recommend five of the most popular articles in the sidebar or at the bottom of the 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>

Passorder="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

AutoCMS provided these two sorting methods are widely used in actual operation:

  • Home page and news dynamic: Usually adopts reverse chronological order by creation time (order="id desc"),Ensure users see the latest information first time.
  • Hot recommendations or top charts:Use the descending order by page viewsorder="views desc"),Highlight the star content of the website to attract clicks.
  • Content aggregation page:For example, an aggregated page for a specific topic can display the latest related articles at the top, and popular articles under the topic can be displayed below, or combinedcategoryIdThe parameter is limited to sorting within a specific category.
  • Product listNew products can be displayed by release time, or recommended best-selling products by views.
  • Manual intervention:except for automatic sorting, when there are important promotions or special events, you can use the custom sorting weight set in the background.order="sort desc"Adjust the priority of content manually to achieve more refined operations.

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 the operation objectives of specific pages.This not only optimizes the user's information acquisition path, but also enhances the overall content value of the website.

Common Questions (FAQ)

Q1: Besides sorting by publishing time and views, what other list sorting methods does Safe CMS support?A: Besides sorting by publish time (id descorid asc) and views (views desc), Anqi CMS also supports sorting by custom sorting weight in the background (order="sort desc"This option allows the operator to manually adjust the importance of the article, so that it is displayed prioritarily in the list.

Q2: I want to display multiple content lists on the same page, such as "Latest Articles" and "Popular Articles", can this be done?A: Absolutely. You just need to use two separatearchiveListtags, and configure them differentlyorderparameters (for example, oneorder="id desc", and the otherorder="views desc") as well as appropriatelimitParameter, you can display a list of content with different sorting logic on the same page.

Q3: If I only want to display the latest articles or popular articles under a specific category, what should I do?A: You can inarchiveListTags, in addition to settingorderParameters, at the same time usingcategoryIdParameters to specify the category to which the content belongs. For example, to display the latest 5 articles with category ID 1, you can write as follows:{% archiveList articles with categoryId="1" limit="5" order="id desc" %}.