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.