How to display the document title, publish time, and view count on the document detail page?
Manage website content in Anqi CMS and ensure its accurate and beautiful display on the front-end page, which is the core of daily operation work.For each document detail page, clearly presenting the document title, publication time, and views can not only effectively improve user experience, but is also an important link in the communication of content information.The Anqi CMS provides powerful and flexible template tags, allowing us to easily meet these requirements.
Locate the document detail page template
To modify the display content of the document detail page, we first need to find the corresponding template file. In the template structure of Anqi CMS, the default template for the document detail page is usually located attemplate/{你的模板目录}/{模型table}/detail.htmlFor example, if your template directory isdefaultthe article model (usuallyarchivethe detail page template for it might betemplate/default/archive/detail.html.
Before making any changes, it is recommended to back up your template file to prevent any errors.
Get and display the document title
The document title is the first step for users to understand the content topic. On the document detail page template, you can directly go througharchiveAn object is used to obtain the title because it represents the document currently being viewed.
To display the document title, you can find the appropriate position indetail.html(usually)<h1>Within the tag), then use the following code:
<h1 class="document-title">{{ archive.Title }}</h1>
archive.TitleIt will directly output the current document title.
Show the document publish time
The publication time of the document can help users understand the timeliness of the content. In Anqicms, the creation time of the document (CreatedTime) is stored in the form of a timestamp. To display it in a human-readable date format, we need to usestampToDatethis label to format the timestamp.
Similarly, you can usearchiveObject retrievalCreatedTimeandstampToDateFormatting. For example, to display in the format 'October 27, 2023 10:30'.
<span class="document-publish-time">发布时间:{{ stampToDate(archive.CreatedTime, "2006年01月02日 15:04") }}</span>
Here, "2006-01-02 15:04" is a special format string used in Go language to define date and time formats. You can adjust this string as needed, for example, to display only the date.("2006年01月02日")Or show the complete year, month, day, hour, minute, and second("2006-01-02 15:04:05").
Display document page views
The page views are a direct indicator of the popularity of a document. In Anqi CMS, the page views of a document can also be obtained directly fromarchivethe object.
To display the document's page views, you can add the code like this:
<span class="document-views">浏览:{{ archive.Views }} 次</span>
You can add units like 'times', 'reads' before or after numbers according to your preference.
Integrate all the information into the template.
The document's title, publication time, and view count are usually displayed together at the top of the content, serving as important metadata. Below is an example of integrating the above elements intodetail.htmlThe template contains example code snippets. We will also add the category and tags of the document to provide a more comprehensive information display.
`twig
{# 文档标题 #}
<h1 class="document-title">{{ archive.Title }}</h1>
<div class="document-meta">
{# 文档所属分类 #}
<span class="meta-item">分类:<a href="{{ archive.Category.Link }}" class="category-link">{{ archive.Category.Title }}</a></span>
{# 文档发布时间 #}
<span class="meta-item">发布时间:{{ stampToDate(archive.CreatedTime, "2006年01月02日 15:04") }}</span>
{# 文档浏览量 #}
<span class="meta-item">浏览:{{ archive.Views }} 次</span>
{# 文档标签,通过 tagList 标签获取并循环显示 #}
{% tagList tags with itemId=archive.Id limit="10" %}
{% if tags %}
<span class="meta-item">标签:
{% for item in tags %}
<a href="{{
Related articles
How to display mathematical formulas and flowcharts on AnQiCMS web pages?
Today, with the increasingly rich digital content, it often seems inadequate to convey complex information solely through text.Especially in fields such as science, technology, and education, mathematical formulas and flowcharts are the key to expressing rigorous logic and clear steps. 幸运的是,AnQiCMS provides a simple and powerful way to easily integrate and display these professional contents on your web page. This article will introduce in detail how to use the Markdown editor and third-party libraries on your AnQiCMS website to achieve perfect presentation of mathematical formulas and flowcharts.
2025-11-08How to correctly render Markdown editor content on the frontend page in HTML?
## AQS CMS Markdown content: How to perfectly present on the front-end page?In content creation, Markdown, with its concise and efficient syntax, has been favored by a wide range of content creators.AnQi CMS knows this and therefore provides strong Markdown editor support.But how can you ensure that the Markdown content you edit in the background is rendered correctly and beautifully on the website's frontend page?Behind this involve several key links, understanding them can help you manage the website content more skillfully.
2025-11-08How can you reference common header, footer, or sidebar content in a template?
In the daily operation and maintenance of the website, we often encounter such situations: each page needs to include a unified header, a standard footer, or a fixed sidebar.If every page were to rewrite this content, it would not only be inefficient but also a huge amount of work to modify once.AnQiCMS (AnQiCMS) understands this pain point and therefore provides a flexible and powerful template reference mechanism to help us efficiently manage these common contents, ensuring the unity and maintainability of the website.### Overview of AnQi CMS Template Mechanism In AnQi CMS
2025-11-08What template file types and directory structures does AnQi CMS support to organize displayed content?
AnQi CMS provides high flexibility and strong organizational capabilities in content display, which is mainly reflected in its support for template file types and directory structures.Understanding these conventions and mechanisms can help you customize the appearance and content layout of the website more efficiently. ### The core structure and conventions of template files Firstly, AnQi CMS will统一存放 all template files used for front-end display in the root directory of the site under the `/template` folder.Each independent website theme or template set should have its own folder in this directory
2025-11-08How to call and display the cover image, thumbnail, or group image of a specified document?
It is crucial to have visually appealing content when building and operating a website.AnQiCMS provides a flexible way to manage and display the images of documents (including articles, products, etc.), whether as an eye-catching cover, a clever thumbnail, or a colorful group photo.Understand how to correctly call these images, which can help you better design and optimize the user experience of the website.AnQiCMS provides several main image fields for different content types, which have clear uses in the template: * **Cover logo (Logo)**
2025-11-08How to implement lazy loading of images in document content to optimize display performance?
## Optimize Website Display Performance: Practical Guide to Implementing Lazy Loading of Images in AnQi CMS In today's internet era, the loading speed of a website is crucial for user experience and search engine rankings.Large image files are often one of the main culprits slowing down website loading speeds. 幸运的是,image lazy loading (Lazy Loading) technology can effectively solve this problem.
2025-11-08How to get and display the name and link of the category to which the current document belongs?
On the content detail page of a website, we often hope to clearly display the classification information of the current document, such as the name of the classification and the link to that classification.This not only helps visitors better understand the content structure, but also improves the website's navigation and user experience.Safe CMS provides us with a variety of flexible ways to meet this requirement. We will discuss several methods for obtaining and displaying the category name and link of the current document in the AnQiCMS template, and you can choose the most suitable solution according to your actual template design and requirements.### Method One
2025-11-08How to display a list of recommended documents related to the current document on the document detail page?
In website content operations, providing users with relevant recommended content not only effectively enhances the depth and duration of page browsing, but also optimizes user experience, indirectly assisting in the SEO performance.In AnQiCMS (AnQi Content Management System), implementing this feature is flexible and direct.Next, we will discuss how to seamlessly integrate and display the recommended document list closely related to the current document on the document detail page. ### Core Value: Why should recommended documents be displayed on the document detail page?
2025-11-08