How to implement the sorting display of article list by views (views desc) in AnQi CMS?

Calendar 👁️ 66

How to make a hot article on the website stand out quickly and attract more visitors' attention?This can not only effectively improve the user experience, but is also the key to optimizing content strategy and guiding traffic.For users using AnQiCMS, it is a very practical and easy-to-operate feature to display article lists sorted by view count.The powerful template tag system of AnQi CMS allows you to easily display the most popular content on your website to users.

Reveal the core features: usingarchiveListTag-based view sorting

AnQi CMS adopted a flexible template tag system, among which,archiveListThe tag is a core tool used to call the article (document) list. To sort articles by views from highest to lowest, you just need to set a key parameter in thearchiveListtag:order="views desc".

The meaning of this parameter is very intuitive:orderRefers to the sorting method,viewsRepresents the article view field, whiledescIt is the abbreviation of 'descending', meaning sorted in descending order. This way, the articles with the highest views will be at the top of the list.

Here is a simple example code that shows how to call a list of articles sorted by page views in descending order in your template:

{# 假设您想在首页或者某个侧边栏显示最新的10篇热门文章 #}
<div class="popular-articles">
    <h2>热门文章推荐</h2>
    <ul>
        {% archiveList archives with type="list" order="views desc" limit="10" %}
            {% for item in archives %}
                <li>
                    <a href="{{ item.Link }}" title="{{ item.Title }}">
                        {{ item.Title }}
                    </a>
                    <span> (浏览量: {{ item.Views }})</span>
                </li>
            {% empty %}
                <li>暂无热门文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In this code block:

  • type="list"The list type is specified as a non-paginated regular list.
  • order="views desc"It is the key to sort by view count in descending order.
  • limit="10"It limits to only display the top 10 articles by view count.
  • {{ item.Link }}and{{ item.Title }}They are used to get the link and title of the article.
  • {{ item.Views }}The article's page views are displayed directly, allowing visitors to see at a glance the popularity of the article.

Practical operation: Where should this code be placed?

After understanding the core code, the next step is to apply it to your website template. The template files of Anqi CMS are usually stored in the system's/templatethe directory, and.htmlsuffix. You can flexibly use the list of articles sorted by page views in the following common locations:

  1. Home page (index/index.html):Set a "Hot Recommendations" or "What Everyone is Watching" area on the homepage to display the highest viewed articles on the site, which can effectively enhance the attractiveness of the homepage.
  2. Category list page ({模型table}/list.html): You can display the most popular articles within a specific category.For example, on the "News Center" category page, you can add a "Weekly Hot News" module.At this time, you may need toarchiveListtagcategoryIdParameters to specify the category of the article, for example:categoryId=currentCategoryId(AssumingcurrentCategoryIdis the ID of the current category).
  3. Sidebar or bottom of the article detail pageWhen reading an article, providing a list of 'related popular articles' can increase the relevance between articles and also extend the user's stay on the website.
  4. Search results pageIn search results, in addition to relevance sorting, you can also provide an option to sort by views, allowing users to quickly find the most popular content.

Edit the template file while ensuring you have a basic understanding of HTML and CSS, so that you can integrate code snippets into the page structure and adjust the style to match the design style of your website.

Where does the browsing volume data come from?

You may be curious, how are these 'view count' data statistics collected?The AnQi CMS is built-in with powerful traffic statistics and crawler monitoring functions.It automatically tracks the visitation of each article on the website and accurately records the number of views (views).You do not need to make any additional configuration, the system will silently collect this data, providing a solid foundation for your content operation.

By using the "Data Statistics" feature on the backend, you can also view more detailed traffic analysis reports, understand which articles are performing well, and which content needs further promotion or optimization.

Advanced Application and Operation Suggestions

Mastering the skill of sorting by page views will make your content operation more skillful:

  • Combined with other parameters:archiveListTags also support various other parameters, such as throughmoduleIdSpecify a specific content model (such as an article model or product model), or throughflag="c"to only display articles with the 'recommended' attribute. You can combine these parameters withorder="views desc"Combine them to create a more refined and operationally suitable article list.
  • A/B test content title and coverObserve the titles and cover images of popular articles, analyze their common characteristics, which can provide inspiration for subsequent content creation.
  • Optimize the structure of internal links.Linking popular articles to other low-relevance but high-quality content can drive overall website traffic and authority.

By reasonably utilizing the functions provided by Anqi CMS,archiveListTags andorder="views desc"Parameters, you can easily build a dynamic display of popular articles list, effectively enhance the user stickiness and content value of the website.


Frequently Asked Questions (FAQ)

Q1: How to display the article list sorted by views in ascending order? A1: If you want to sort by views in ascending order, just setorderthe value of the parameter fromviews descis modified toviews asc.{% archiveList archives with type="list" order="views asc" limit="10" %}.

Q2: Can I display the article with the highest views in a specific category at the same time? A2: Of course. You just need toarchiveListSpecify at the same time in the tagcategoryIdthe parameter. For example, to display the category ID of1The top 5 articles with the highest views under the category, you can write it like this:{% archiveList archives with type="list" categoryId="1" order="views desc" limit="5" %}.

Q3: Besides the article title and views, what other article information can I display? A3: archiveListIn the tag loop body,itemThe variable contains many details about the article, such as:

  • {{ item.Link }}: Article link
  • {{ item.Title }}: Article title
  • {{ item.Description }}: Article summary
  • {{ item.Views }}: Views
  • {{ item.Logo }}: Article cover image
  • {{ stampToDate(item.CreatedTime, "2006-01-02") }}: Article publish date (it is necessary to usestampToDatetags for formatting) You can freely choose and combine this information as needed.

Related articles

How to display the language switch options and hreflang tags on Anqi CMS?

Today, providing multilingual support for websites has become a basic requirement for expanding the market and serving users in different regions.AnQiCMS (AnQiCMS) is fully aware of this need, integrating powerful multilingual functionality to allow website administrators to easily achieve content internationalization.This article will discuss in detail how to effectively display language switch options on AnQiCMS sites and correctly set the `hreflang` tag to optimize the internationalization recognition of search engines.Understanding AnQiCMS' multilingual capabilities AnQiCMS is an efficient

2025-11-09

How does the `breadcrumb` tag in AnQi CMS generate and display flexible breadcrumb navigation?

When building a website, a clear and intuitive navigation system is crucial for user experience and search engine optimization (SEO).Breadcrumb navigation is a tool that can significantly improve website usability, clearly showing the user's current position on the site and providing convenient links to return to the previous level page.AnQi CMS knows this and provides a powerful and flexible `breadcrumb` tag.###

2025-11-09

How to define and display temporary variables in Anqi CMS template for complex content layout?

In website content operation, we often encounter some scenes where we need to flexibly display data and dynamically adjust the layout.Sometimes listing information simply is not sufficient to meet complex design requirements, and at this point, if you can freely define and use some temporary variables in the template, it will greatly enhance our efficiency and the expressiveness of the template.AnQiCMS (AnQiCMS) with its powerful backend developed based on the Go language and the template engine syntax similar to Django, provides us with a flexible mechanism for defining and managing temporary variables, making it possible to create exquisite and complex content layouts.Define a temporary variable

2025-11-09

How can AnQi CMS display a list of recommended articles related to the current article content?

In website operation, providing a list of recommended articles related to the current content is an important strategy to enhance user experience, extend user stay time, and optimize website internal links.AnQiCMS (AnQiCMS) knows this and provides flexible and powerful features to help you easily achieve this goal.### Core Function Analysis: Related Document Tag `archiveList` To display a list of recommended articles related to the current article content in AnQi CMS, you will mainly use a very key template tag—`archiveList`

2025-11-09

How to implement complex parameter filtering conditions for the dynamic display of the `archiveFilters` tag on the front end?

In website content operation, providing users with flexible and efficient filtering functions is an important factor in improving user experience and helping users quickly locate the information they need.AnQiCMS (AnQiCMS) knows this, making it easy to dynamically display complex parameter filtering conditions on the front end through its powerful template tag system, especially the `archiveFilters` tag.### Core Function and Implementation Principle The core function of the `archiveFilters` tag is to use the custom fields of the content model

2025-11-09

How to call the backend custom Json-LD structured data in AnQi CMS template and display it?

Today with the rich content on websites, how to make search engines accurately understand web content and display it in a more user-friendly manner has become a key link in website operation.Structured data (usually in Json-LD format) is an important tool to achieve this goal.By embedding Json-LD code in the page, we can provide standardized information for search engines about various content such as articles, products, and reviews, thereby having the opportunity to obtain richer search result displays, which is what we commonly refer to as 'rich snippets' or 'rich results'

2025-11-09

How does Anqi CMS handle and display external links in content, such as adding the `rel="nofollow"` attribute?

In website operation, the management of external links is an indispensable part of content strategy and search engine optimization (SEO).Especially properties like `rel="nofollow"`, which tell search engines not to pass link weight to the linked page, are crucial for managing the link health of a website and avoiding potential SEO risks.AnQiCMS (AnQiCMS) provides multiple ways to handle and display external links in content, including automatically adding the `rel="nofollow"` attribute

2025-11-09

How to correctly display and load images on the front-end page after the website enables Webp image format?

In website operation, the speed of image loading is crucial for user experience and Search Engine Optimization (SEO).WebP is a modern image format that, with its excellent compression performance, significantly reduces file size while maintaining image quality, thus greatly enhancing website loading speed.AnQiCMS (AnQiCMS) fully understands this and has built-in support for WebP image format in its system, making it easy for users to turn it on and benefit from it.However, after enabling the WebP feature, many users may be confused: how can the front-end page correctly display and load these WebP images

2025-11-09