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" %}.