How to implement sorting display of content in a document list by the latest, the hottest, and other methods?

Calendar 👁️ 79

When you manage website content, how to effectively organize and display a document list so that it conforms to user habits and highlights the key points is a very critical link.AnQiCMS provides flexible and powerful features, allowing you to easily implement various sorting and filtering of document content, whether it is by the latest release, most popular, or other customized methods.

In AnqiCMS, flexible display of the document list is mainly achieved through powerfularchiveListThe template tag to implement. This tag is the core tool for obtaining and controlling the content list, by configuring different parameters, you can define the sorting rules, filtering conditions, and display quantity of the content.

Implement sorting by the latest content

When you want users to see the latest content on the website first, you can usearchiveListlabel'sorderthe parameter and set it toid desc. Here,idIt refers to the unique identifier of the document, which is usually positively correlated with the publication time,descThe content is arranged in descending order, meaning that the content with a higher ID value (usually meaning it was published later) is placed at the front.

For example, if you want to display the latest 10 articles on the homepage or other pages, you can write the template code like this:

{% archiveList archives with type="list" limit="10" order="id desc" %}
    {% for item in archives %}
    <div class="article-item">
        <a href="{{ item.Link }}">{{ item.Title }}</a>
        <span>发布时间: {{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
    </div>
    {% endfor %}
{% endarchiveList %}

Implement sorting by the most popular content

Highlight the most popular or highly viewed content on the website, you canorder="views desc"Parameter to achieve.viewsrepresent the document's page views, set todescAfter, documents with higher views will be displayed first. This is very effective for discovering hot topics or promoting important content.

For example, display the 5 most popular articles:

{% archiveList archives with type="list" limit="5" order="views desc" %}
    {% for item in archives %}
    <div class="hot-article-item">
        <a href="{{ item.Link }}">{{ item.Title }}</a>
        <span>浏览量: {{ item.Views }}</span>
    </div>
    {% endfor %}
{% endarchiveList %}

Implement custom sorting

In addition to the built-in latest and hottest sorting of the system, AnqiCMS also allows you to manually set the display order of documents through the backend. This is usually done byorder="sort desc"To implement.When you manage documents in the background, you can set a 'Display Order' value for each document, and the system will sort according to this value.This is very useful for scenarios that require manual intervention to highlight specific content, such as recommended articles or special topics.

When calling in the template, you can use it like this:

{% archiveList archives with type="list" limit="8" order="sort desc" %}
    {% for item in archives %}
    <div class="featured-article-item">
        <a href="{{ item.Link }}">{{ item.Title }}</a>
    </div>
    {% endfor %}
{% endarchiveList %}

Combine multiple conditions for filtering and sorting

The strength of AnqiCMS lies in the ability to combine these sorting rules with various filtering conditions to create highly customized content lists.archiveListTags support multiple filtering parameters, such as:

  • categoryId: Filter content based on the ID of a specific category.
  • flag: Filter based on the recommended attributes of the document (such as headlines, recommendations, slides, etc.).
  • q: Filter by search keywords.
  • type="page": If you need to display content with pagination, you must set this parameter and combine it withpaginationlabel usage

For example, under a specific category (ID 10), display the latest recommended articles and perform pagination:

{% archiveList archives with type="page" categoryId="10" flag="c" order="id desc" limit="10" %}
    {% for item in archives %}
    <div class="category-recommended-item">
        <h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
        <p>{{ item.Description|truncatechars:100 }}</p>
    </div>
    {% empty %}
    <p>该分类下暂无推荐文章。</p>
    {% endfor %}
{% endarchiveList %}

<div class="pagination-container">
    {% pagination pages with show="5" %}
        {# 这里可以放置分页链接的代码,例如:#}
        {% if pages.PrevPage %}<a href="{{ pages.PrevPage.Link }}">上一页</a>{% endif %}
        {% for item in pages.Pages %}<a href="{{ item.Link }}" class="{% if item.IsCurrent %}active{% endif %}">{{ item.Name }}</a>{% endfor %}
        {% if pages.NextPage %}<a href="{{ pages.NextPage.Link }}">下一页</a>{% endif %}
    {% endpagination %}
</div>

exceptarchiveListIf you need a more complex, content model-based custom field filtering feature,archiveFiltersTags can also be useful. They can help you generate filter condition groups, such as filtering by 'type' or 'area' on real estate websites, and then applying sorting on this basis.

Summary

By flexible applicationarchiveListtags and theirorderParameters, you can easily adjust the display method of the content list according to the website operation requirements.Whether it is pursuing the "latest" for timeliness, emphasizing the "hot" user attention, or fine-grained operation "custom sorting", AnqiCMS provides intuitive and easy-to-operate solutions.The combination of these features will greatly enhance the organization efficiency and user access experience of the website's content.


Frequently Asked Questions (FAQ)

1. Can I display a list of documents with different sorting rules on the same page?Absolutely, you can. You just need to use multiple templates in the template file.archiveListLabel, and configure different parameters for each labelorderParameters andlimitJust set the parameters. For example, one list displays the latest articles, and another list displays the most popular articles.

2. Besides the latest and the hottest, what other sorting methods are built into AnqiCMS?AnqiCMS supports sorting by document ID in descending order (id descThis usually represents the latest release, sorted by view count in descending orderviews descThis represents the most popular, as well as custom sorting on the backendsort desc)。The value of custom sorting needs to be manually set when editing documents in the AnqiCMS backend.

3. Why didn't the front page take effect immediately after I modified the sorting rules in the template?This is usually due to website caching.In AnqiCMS backend, you can find the "Update Cache" feature, after clicking on Clean Cache, the front page will display the latest sorting effect.Moreover, browser cache may also affect display, it is recommended to clear the website cache as well as the browser cache or access in incognito mode after clearing the website cache.

Related articles

How to customize the prompt information page displayed to users when the website is closed?

When a website needs to be maintained, upgraded, or temporarily suspended, displaying a friendly prompt page to visitors instead of a cold error message is crucial for improving user experience and maintaining brand image.AnQiCMS (AnQiCMS) is well-versed in this, providing a flexible and convenient way for you to easily customize the prompt information page when the website is closed. ### The shutdown handling mechanism of AnQi CMS AnQi CMS is built with website status management functions, allowing you to control the visibility of your website to the outside world with one click.In the background "Global Function Settings"

2025-11-08

How to set up the website logo and filing number and ensure they are displayed correctly on the page?

## SecureCMS: Website Logo and Filing Number Setup and Display Guide A professional and compliant website cannot do without a clear brand identity (Logo) and necessary legal information (such as filing number).The Anqi CMS provides a convenient way to manage these important website elements and ensures they are displayed correctly on the page.This article will introduce in detail how to set your website logo and filing number in the Anqi CMS background, as well as how to correctly refer to them in the website template.### One, set up in the background First

2025-11-08

If the document does not upload a thumbnail, how to ensure that the page displays a default placeholder image?

The use of images is the key to enhancing the attractiveness of the page in website content operation.Especially the thumbnail, it plays the role of a 'facade' in scenarios such as list pages, recommendation positions, and so on.However, in the process of daily content publishing, there may be a lack of thumbnails due to negligence or the content itself not containing images, which not only affects the aesthetics and professionalism of the page, but may also reduce the desire of users to click.Luckyly, AnqiCMS provides us with a comprehensive solution to ensure that the page can display a default placeholder image gracefully even if the document does not upload a thumbnail.

2025-11-08

How do various thumbnail processing methods (such as cropping and scaling) affect the display effect of images on the page?

The display effect of website images directly affects the first impression and attractiveness of the content for users.Among them, the thumbnail serves as the 'facade' of the content, and its presentation is particularly crucial.AnQiCMS (AnQiCMS) has provided us with a variety of flexible thumbnail processing options, allowing us to finely control the display effect of images on the page according to different design requirements.Next, let's delve into the characteristics of each of these processing methods, as well as how they will affect the visual presentation of our website.

2025-11-08

How can I obtain and display the links and titles of the previous/next document on the document detail page?

In website content operation, adding "Previous" and "Next" navigation to the document detail page is a common strategy to improve user experience, guide users to deeply browse, and optimize the internal links of the website.AnQiCMS is a content management system that fully considers these needs and provides intuitive and simple template tags, allowing you to easily achieve this function.### The advantage of AnQiCMS implementing the "Previous/Next" navigation AnQiCMS's template system is designed ingeniously, adopting syntax similar to the Django template engine, by

2025-11-08

How to call and display the latest article list in AnQi CMS?

As a feature-rich and easy-to-use content management system, AnQi CMS provides great flexibility in content display.When you need to show your visitors the latest articles on the website, such as on the homepage, sidebar, or specific topic pages, Anqi CMS can help you easily achieve this.To implement the "Display the latest article list in Anqi CMS", the core lies in flexibly using its powerful template tag system, especially the `archiveList` tag.

2025-11-08

How to customize the layout and content of the document detail page in AnQi CMS?

In Anqi CMS, the custom display layout and content of the document detail page are crucial for realizing website personalization and meeting specific business needs.The ultimate form of website content, detail pages not only carry core information but also directly affect user experience and search engine optimization effects.The AnQi CMS offers a highly flexible template mechanism and rich data tags, allowing users to easily create unique document detail pages according to their own creativity.

2025-11-08

How to use AnQi CMS template tags to get the document list under a specific category?

AnQiCMS (AnQiCMS) provides a solid foundation for flexible display of website content with its powerful template features.In website operation, we often encounter the need to display a list of documents under specific categories, such as news updates, product introductions, blog articles, and so on.Mastering how to utilize template tags to achieve this function will greatly enhance the organization efficiency and user experience of the website content.### Core Tag: The Usefulness of `archiveList` In AnQi CMS, you need to get the document list under a specific category

2025-11-08