How to make popular articles on the website stand out quickly and attract more visitors' attention?This not only effectively improves 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 the article list sorted by views.The strong template tag system of AnQi CMS allows you to easily present the most popular content of the website to users.
Reveal the core features: utilizingarchiveListLabel implementation of page view sorting
The Anqi CMS adopts a flexible template tag system, where,archiveListTags are core tools used to call the list of articles (documents). To sort articles by view count from high to low, you only need to set a key parameter in the tags:archiveListTags set a key parameter:order="views desc".
The meaning of this parameter is very intuitive:orderIndicates the sorting method,viewsRepresents the field of article views,descThen it is the abbreviation of 'descending', indicating that the sorting is in descending order. In this way, the articles with the highest page views will be placed at the top of the list.
The following is a simple example code that demonstrates how to call the article list sorted by 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 type of the list is specified as a non-paginated regular list.order="views desc"It is the key to sort by the number of views in descending order.limit="10"It limits the display to the top 10 articles with the highest number of views.{{ item.Link }}and{{ item.Title }}They are used to retrieve the link and title of the article.{{ item.Views }}The article's view count is displayed directly, allowing visitors to see the popularity of the article at a glance.
Practical Operation: Where should this code be placed?
Understood 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/templatedirectory, and named with.htmlEnglish suffix. You can flexibly use the article list sorted by views in the following common locations:
- Home page (
index/index.html)In the homepage settings, set up a "Hot Recommendations" or "What Everyone is Watching" area to display the articles with the highest page views on the site, which can effectively enhance the attractiveness of the homepage. - Category list page (
{模型table}/list.html)In a specific category, you can display the most popular articles within that category.For example, on the "News CenterarchiveListAdditional tags addedcategoryId参数来指定文章所属的分类,例如:categoryId=currentCategoryId(假设currentCategoryId是当前分类的ID)。 - 文章详情页的侧边栏或底部In reading an article, providing a list of 'related hot articles' can both increase the relevance between articles and extend the user's stay on the website.
- Search results pageIn the search results, in addition to relevance sorting, an option to sort by views can also be provided, allowing users to quickly find the most popular content.
Please ensure you have a basic understanding of HTML and CSS when editing template files, so that you can integrate code snippets into the page structure and make style adjustments to maintain consistency with your website design style.
How many page views come from?
You may be curious, how are these 'page views' data counted?The Auto CMS is equipped with powerful traffic statistics and spider monitoring functions.It will automatically track the access of every article on the website and accurately record 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.
Through the "Data Statistics" feature on the backend, you can also view more detailed traffic analysis reports to understand which articles are performing well and which content needs further promotion or optimization.
Advanced Application and Operation Suggestions
Once you master the skill of sorting by views, your content operation will be more proficient:
- 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 use to create a more refined, more in line with operation requirements article list. - A/B test content title and cover:Observe the titles and cover images of popular articles, analyze their common characteristics, which can provide inspiration for subsequent content creation.
- Optimize the internal link structure:Link popular articles to other articles with lower relevance but high-quality content can drive the overall traffic and authority of the website.
By reasonably utilizing the CMS provided by AnqiarchiveListTags andorder="views desc"Parameters, you can easily build a dynamic display of hot content article list, effectively improve the website user stickiness and content value.
Common Questions (FAQ)
Q1:How to sort the article list by view count from low to high (ascending)?
A1:If you want to sort by view count from low to high (ascending), just setorderthe value of the parameter fromviews descChange toviews ascIt is. For example:{% archiveList archives with type="list" order="views asc" limit="10" %}.
Q2:Can I display the article with the highest views under a specific category at the same time?
A2:Of course. You just need to set thearchiveListin the same tagcategoryIdparameter. For example, to display the category ID of1的分类下浏览量最高的5篇文章,可以这样写:English{% archiveList archives with type="list" categoryId="1" order="views desc" limit="5" %}.
Q3:除了文章标题和浏览量,我还能显示哪些文章信息?English
A3: archiveList标签循环体中的EnglishitemThe variable contains many details of the article, such as:
{{ item.Link }}: Article link{{ item.Title }}: Article title{{ item.Description }}: Article summary{{ item.Views }}: Page views{{ item.Logo }}: English article cover image{{ stampToDate(item.CreatedTime, "2006-01-02") }}: Article publish date (it is required to usestampToDatetags to format) You can freely select and combine this information to display as needed.