How to call and display the views (Views) of Anqi CMS documents?

Calendar 👁️ 59

As an experienced website operations expert, I know that every data indicator contains profound insights into the performance of website content and user behavior.In AnQiCMS (AnQiCMS) such an efficient and practical content management system, the flexible invocation and display of core data such as "document views" are indispensable abilities for content operators.This not only helps us understand the popularity of the content intuitively, but is also an important basis for optimizing content strategies and improving user experience.

AnQi CMS, with its high-performance architecture developed in Go language, excels in data processing and template rendering, making it convenient and efficient to call various data.Today, let's delve into how to elegantly call and display the number of views of an article in Anqi CMS template.

The 'Views' in AnQi CMS: data value and convenient call

Under the context of website operation, document views are not just a simple number; they represent the interest of users in the content and are an important indicator of the attractiveness of the content.High traffic usually means that the content has stronger dissemination and user stickiness.

  • Enhance the credibility of the content:Users tend to read content that has been viewed by more people, forming a herd effect.
  • Guide users to discover popular content:Help visitors quickly identify popular articles or products on the website.
  • Inspire content creators:Intuitive data feedback can inspire the creativity of the content team.

AnQi CMS knows these operational needs and therefore, from the beginning of its design, it has included views (Views) as an intrinsic attribute of content models such as articles, products, and more, making it extremely simple to call and display through its powerful template tag system.

Core feature analysis: How to call document page views?

In AnQi CMS, document view calls are mainly achieved through two scenarios: one is to display the detailed view of a single document, and the other is to display the view of a list of multiple articles.

One, display the browsing volume of a single document on the document details page

When a visitor clicks to enter a detailed page of a document, we usually want to see the specific number of times this article has been read. AnQi CMS provides for thisarchiveDetailTags, allowing you to easily obtain detailed information about the current document, including views.

archiveDetailThe design of tags is very flexible. When not specifiedidortokenIn the case of the parameter, it will automatically recognize the current page's document. You need toname="Views"parameter to explicitly tell the system that you want to retrieve the browsing volume data of the document.

Let's look at an example code that shows how to display the document title, publish time, and view count on the document detail page:

<article class="document-detail">
    {# 获取并显示文档标题 #}
    <h1 class="document-title">{% archiveDetail with name="Title" %}</h1>

    <div class="document-meta">
        {# 获取并显示文档发布时间,使用stampToDate标签进行格式化 #}
        <span>发布时间:{{ stampToDate(archive.CreatedTime, "2006-01-02") }}</span>
        {# 获取并显示文档浏览量 #}
        <span>浏览量:{% archiveDetail with name="Views" %}次</span>
    </div>

    <div class="document-content">
        {# 显示文档内容,并安全解析HTML #}
        {%- archiveDetail articleContent with name="Content" %}
        {{articleContent|safe}}
    </div>
</article>

In the code above,{% archiveDetail with name="Views" %}This line will directly output the number of views of the current document. We can add units such as 'times' or 'readings' after the number to make it more readable. It is important to note,archive.CreatedTimeAssumingarchiveIt is a globally available current document object, itsCreatedTimeis a timestamp that needs to be formatted with astampToDatetag. If the object is not available, you can also usearchivethe same object.{% archiveDetail with name="CreatedTime" %}Get the timestamp and then format it.

Second, display the number of views for multiple articles on the document list page.

On the homepage, category list page, Tag list page, or search results page, we often need to display an overview of multiple articles, including the number of views for each article, so that users can quickly filter the content they are interested in. AnQi CMS'sarchiveListandtagDataListTags are a powerful tool for handling such scenarios.

When you arearchiveListortagDataListusing tags insideforWhen looping through a list of articles, the data of each article will be assigned to a loop variable (for example, in the following example it isarticle). At this point, you can directly access the variable'sViewsProperties to get page views.

The following code demonstrates how to display the title, description, and page views of each article on the article list page:

<div class="article-list">
    {# 使用archiveList标签获取文章列表,并指定为分页模式,每页显示10条 #}
    {% archiveList articles with type="page" limit="10" %}
        {% for article in articles %}
        <div class="article-item">
            <a href="{{ article.Link }}" class="article-link">
                <h3 class="article-title">{{ article.Title }}</h3>
                <p class="article-description">{{ article.Description }}</p>
                <div class="article-meta">
                    {# 显示文章发布时间 #}
                    <span>发布时间:{{ stampToDate(article.CreatedTime, "2006-01-02") }}</span>
                    {# 直接访问循环变量的Views属性显示浏览量 #}
                    <span>浏览量:{{ article.Views }}次</span>
                </div>
            </a>
        </div>
        {% empty %}
        <p class="no-content">暂无更多文章。</p>
        {% endfor %}
    {% endarchiveList %}

    {# 如果是分页列表,别忘了调用分页标签 #}
    <div class="pagination-controls">
        {% pagination pages with show="5" %}
            {# 这里省略分页的具体HTML结构,但确保它被正确调用 #}
            ...
        {% endpagination %}
    </div>
</div>

In this example,{{ article.Views }}Directly from the loop.articleThe object retrieved the current page views.type="page"Parameter indicationarchiveListGenerate pagination data, andpaginationThe tag is responsible for rendering the complete

Related articles

How to get the ID and name of the current document category?

In the daily operation of AnQi CMS, content classification is a key element for organizing information, enhancing user experience, and optimizing SEO.Whether it is to generate breadcrumb navigation for articles, or to display other content under the current category in the sidebar, or to set dynamic titles for category pages, obtaining the ID and name of the current document's category is a common requirement in template development.The Anqi CMS provides intuitive and powerful template tags, allowing you to easily call this information on the front-end page.

2025-11-06

How to extract and display the list of hierarchical titles (H1-H6) in the AnQiCMS document content?

## Mastering the Ride: AnQiCMS How to Intelligently Extract and Display Hierarchical Titles (H1-H6) As an experienced website operations expert, I deeply understand the importance of content structure for user experience and search engine optimization.When dealing with a large amount of document content, it is crucial to clearly understand and efficiently utilize the hierarchical title structure (H1-H6) within the document to enhance the value of the website content.AnQiCMS (AnQiCMS) is an efficient enterprise-level content management system that provides very intuitive and powerful functions in this aspect.

2025-11-06

How to correctly display the rich text content of AnQiCMS documents and support lazy loading of images?

As an experienced website operations expert, I am willing to delve into the strategy of rich text content display and image lazy loading in AnQiCMS.In today's increasingly rich digital content, efficiently and beautifully presenting content while considering user experience and website performance is a focus for every operator.AnQiCMS is an efficient CMS based on the Go language, providing powerful tools to achieve these goals.

2025-11-06

How to generate a permanent link for documents in the AnQiCMS template?

## How to generate a permanent link for documents in AnQiCMS template: A comprehensive guide from backend configuration to frontend display In the operation of a website, a clear, easy-to-understand, and SEO-friendly permanent link (Permalink) is invaluable.It not only improves user experience, allowing visitors to identify page content at a glance, but is also the foundation of website SEO optimization.A stable and semantically meaningful URL structure can effectively help search engines crawl and understand your content, thereby affecting the ranking performance of the website.AnQiCMS knows this

2025-11-06

How to set and call the recommended attribute (Flag) of the document in AnQiCMS?

## AnQiCMS High-efficiency Operation Manual: Mastering the Settings and Calls of Document Recommendation Attributes (Flag) As an experienced website operations expert, I am well aware that how to make your high-quality content stand out in the vast sea of digital content and accurately reach your target users is the key to success.AnQiCMS as a powerful content management system, its built-in "Flag" feature is a powerful tool to help content achieve fine-grained operation.It can not only help you flexibly organize and display content, but also effectively enhance the exposure and user perception of the content. Today

2025-11-06

How does Anqi CMS display the cover image and thumbnail of the document?

As an experienced website operations expert, I know the importance of a high-quality cover image and a proper thumbnail for the attractiveness of the website, user experience, and even search engine optimization (SEO).AnQiCMS (AnQiCMS) deeply understands this, and its design in image processing and display is not only powerful in function but also takes into account the convenience of operation and flexibility of display. Let's delve into how Anqi CMS cleverly displays document cover images and thumbnails.

2025-11-06

How to display multiple cover group images in a document detail page?

As an expert who deeply understands website operation, I know that high-quality, visually appealing content is the key to retaining users and enhancing the value of the website.AnQiCMS (AnQiCMS) is a powerful content management system that provides great flexibility in content presentation.Today, let's delve into a common need: how to cleverly loop multiple cover group images on the document detail page to make the content more expressive. --- ## Secure CMS: Delicate Presentation!A guide to displaying multiple cover group images in document detail pages In the era of content is king

2025-11-06

How to format the display of the release and update time of AnQiCMS documents?

As an experienced website operations expert, I am well aware that the accuracy and readability of time in content display are crucial for user experience and Search Engine Optimization (SEO).AnQiCMS as an efficient and flexible content management system provides a very convenient way to control the display format of the publication and update time of articles.This article will focus on how AnQiCMS formats and displays the publication and update times of documents, and will explain the secrets and practical skills in detail.

2025-11-06