How to display the title, category, time, and other core information on the AnQiCMS document detail page?

Calendar 👁️ 61

Manage website content in AnQiCMS, the document detail page is undoubtedly the core interface for users to obtain information.How to make this page both beautiful and informative is a concern for many website operators.Today, let's talk about how to elegantly display the title, category, publication time, and other key information on the document detail page of AnQiCMS.

AnQiCMS uses a concise syntax similar to the Django template engine, which makes it very intuitive to call various data when customizing templates. For the document detail page, the system usually provides a default namedarchiveThe global variable, which contains all the detailed data of the current document. This means that we can directly accessarchive.字段名in a simple way to obtain and display the required information.

Retrieve and display the document title

Firstly, the title of the document is the soul of the page. In your document detail template file (usuallydetail.htmlOr you can use a template customized according to the content model{{archive.Title}}to display the title. Usually, we would place it in<h1>tags to highlight their importance and be SEO-friendly:

<h1>{{archive.Title}}</h1>

If your document is set with SEO title and you want it to be displayed on the page<title>You can use the tag totdkTag to automatically obtain:

<title>{% tdk with name="Title" siteName=true %}</title>

HeresiteName=trueIt will automatically add the website name at the end of the title,sepProperty (default as-) can be used to define a delimiter.

Display the document's category

The classification of the article can help readers quickly understand the article's归属, and it is convenient for them to browse similar content. ThrougharchiveVariable, we can also easily obtain classification information:

<a href="{{archive.Category.Link}}">{{archive.Category.Title}}</a>

here,archive.CategoryIt is an object that contains detailed information about the classification of the current document, such as the classification linkLinkand the classification nameTitle. Click on the category name, and readers can jump to the list page of that category.

Show the document publishing and update time

Time information is particularly important for news and technical articles, as it allows readers to understand the timeliness of the information. AnQiCMS providesCreatedTime(Publishing time) andUpdatedTime(Update time) two fields. These fields store timestamps, and we need to usestampToDatea function to format it into a readable date and time.

For example, display the publication time:

<span>发布时间:{{stampToDate(archive.CreatedTime, "2006-01-02 15:04")}}</span>

Here"2006-01-02 15:04"It is the time formatting standard of Go language, which represents specific year, month, day, hour, and minute. You can adjust this format as needed, such as displaying only the date.("2006-01-02")Or more detailed time("2006-01-02 15:04:05"). If the article is updated, you can also similarly display the update time{{stampToDate(archive.UpdatedTime, "2006-01-02")}}.

Enrich page information: View count and tags

To make the detail page content richer, you can also display the number of views and related tags.

Views: {{archive.Views}}It can directly display the number of reads of the article, increasing the attractiveness of the article.

Document Tag:Tags can help readers quickly understand the main keywords of the article and find more related content. AnQiCMS goes throughtagListTags to get the list of related tags of the article and need to be combined withforloop to iterate and display:

{% tagList tags with itemId=archive.Id limit="10" %}
    {% for item in tags %}
        <a href="{{item.Link}}">{{item.Title}}</a>
    {% endfor %}
{% endtagList %}

HereitemId=archive.IdMake sure to get the tags of the current document,limit="10"which limits the maximum number of tags displayed to 10.

Integration of code examples

Combine the above content, and your document detail page template may look like this (for brevity, the CSS style is omitted):

{% extends 'base.html' %} {# 继承基础模板,通常包含头部、底部等公共部分 #}

{% block content %}
<article>
    {# 文档标题 #}
    <h1>{{archive.Title}}</h1>

    <div class="meta-info">
        {# 分类信息 #}
        <span class="category">
            所属分类:<a href="{{archive.Category.Link}}">{{archive.Category.Title}}</a>
        </span>
        
        {# 发布时间 #}
        <span class="publish-time">
            发布日期:{{stampToDate(archive.CreatedTime, "2006年01月02日")}}
        </span>
        
        {# 更新时间(如果需要显示) #}
        {% if archive.UpdatedTime > archive.CreatedTime %} {# 仅在更新时间晚于发布时间时显示 #}
        <span class="update-time">
            更新日期:{{stampToDate(archive.UpdatedTime, "2006年01月02日")}}
        </span>
        {% endif %}
        
        {# 浏览量 #}
        <span class="views">
            阅读量:{{archive.Views}}
        </span>
    </div>

    {# 文档标签 #}
    <div class="tags">
        标签:
        {% tagList tags with itemId=archive.Id limit="10" %}
            {% for item in tags %}
                <a href="{{item.Link}}">{{item.Title}}</a>
            {% endfor %}
        {% endtagList %}
    </div>

    {# 文档内容 #}
    <div class="article-content">
        {{archive.Content|safe}}
    </div>
</article>
{% endblock %}

Please note,{{archive.Content|safe}}of|safeIt is a very important filter that tells AnQiCMS to render HTML content (such as the output from a rich text editor) as safe HTML directly, rather than escaping it. If your article content contains images, links, and other HTML tags, be sure to add|safeThese tags may be displayed as plain text if not specified.

Practical suggestions and tips

  • Template location:The template files for the document detail page are usually located in your template directory.{模型table}/detail.htmlFor example, if it is an article model, it may bearticle/detail.html.
  • Custom field:If you add custom fields (such as "author", "source") in the background for the content model, you can also do so by{{archive.你的自定义字段名}}Display. If you want to loop through all custom parameters, you can usearchiveParams.
  • SEO optimization:Don't forget to use in addition to displaying titles and keywords in the page contenttdkThe tag is in<head>to set up the page correctly<title>/<meta name="keywords">and<meta name="description">This will have a positive impact on search engine inclusion and ranking.
  • Debug variable: If you are unsure during template development processarchiveYou can use to see what data is in the variable.{{archive|dump}}The filter prints out all its structures and values, which is very helpful for debugging.

With these simple yet powerful tags and techniques, you can easily display all core information on the document detail page of AnQiCMS, providing your readers with a clear and comprehensive reading experience.


Frequently Asked Questions (FAQ)

How to adjust the display order and style of titles, categories, time, and other information?The display order of this information is entirely dependent on the order you write in the template HTML code.You can freely adjust their positions according to design requirements. As for the style, AnQiCMS front-end template is essentially HTML and CSS, you just need to add the corresponding HTML tags to this information in the template file (such as<h1>/<span>/<a>),then control their font size, color, spacing, and other appearance styles through the CSS file.

2. Besides the article title, category, time, and view count, what other information can I display? archiveVariables include many built-in fields of the document, such asDescription(Summary),Logo(Cover main image),Thumb(thumbnail),Images(Group image) etc. Moreover, if you have customized additional fields for the content model in the background

Related articles

How to implement a multi-level menu and content联动 display on the AnQiCMS website navigation list?

The website's navigation system is like the skeleton of a building, it not only guides users to browse but also directly affects the exposure of content and search engine optimization.AnQiCMS provides a flexible and powerful navigation management function, allowing you to easily build multi-level menus and achieve deep linkage with website content, thereby enhancing user experience and content distribution efficiency. ### Flexible configuration, build a multi-level navigation skeleton The starting point of implementing a multi-level menu in AnQiCMS is the navigation settings in the background.You can find all configuration items related to website navigation under the 'Background Settings' and 'Navigation Settings' first.

2025-11-08

How to set and display search engine friendly TDK (Title, Description, Keywords) for AnQiCMS pages?

Search engine optimization (SEO) is an indispensable part of website operation, and the Title (title), Description (description), and Keywords (keywords) - abbreviated as TDK - of the website page are the foundation of SEO.They are the first step for search engines to understand page content and a key factor for users to decide whether to click on search results.

2025-11-08

How to dynamically display the contact information of the website in AnQiCMS templates?

In website operation, clearly and accurately displaying the website's contact information is a key link in building trust with users and providing support.A contact method that is easy to find and keep updated, which can not only improve the user experience but also help users find you quickly when necessary.AnQiCMS as an efficient content management system provides a very flexible and intuitive way for you to dynamically display and manage this important information in website templates.

2025-11-08

How to correctly call and display the system configuration information in AnQiCMS templates?

Manage website content in AnQiCMS, it is not just to publish articles and products, but also includes the basic information, contact information, SEO metadata and other system-level configurations of the website.These configuration information is usually required to be displayed correctly on all pages of the website, such as displaying the website logo and name in the page header, displaying the copyright and filing number in the footer, or displaying the company's phone number and address on the contact us page.Properly and flexibly invoking these system configurations is the key to ensuring consistency, ease of maintenance, and SEO-friendliness of the website.AnQiCMS uses syntax similar to the Django template engine

2025-11-08

How to filter and display a specific content list based on the 'recommended properties' of the document?

How to effectively organize and display a large amount of content when operating a website is the key to improving user experience and content value.AnQiCMS provides a very practical feature, that is, to refine the management and filtering of content lists through 'recommended attributes'.This not only makes the website content more dynamic, but also helps visitors find the information they are interested in more quickly.### Understanding "Recommended Properties": A Tool for Content Organization In Anqi CMS, when we publish or edit documents, we will find an option called "Recommended Properties"

2025-11-08

How to optimize the display and lazy loading of images and videos in document content?

In today's content-driven internet environment, images and videos have become key elements in attracting users and enhancing page interaction.However, they are often the main culprits that lead to slow website loading and a decline in user experience.As users of AnQi CMS, we are fortunate to have a powerful and flexible system that not only efficiently manages content but also has many built-in features to help us cleverly optimize the display of images and videos, and realize smart lazy loading, so that the content can also 'fly' while ensuring visual effects.

2025-11-08

How to extract and display the first image in the document content as a thumbnail?

In website operation, it is a key to enhance click-through rate and optimize user experience to equip each article or product with an attractive thumbnail.However, manually creating and uploading thumbnails for a large amount of content will undoubtedly take a lot of time and effort.Our company, AnQi CMS, is well-versed in this field and provides us with an intelligent and efficient thumbnail processing solution, making website content management easier. ### The Intelligent Thumbnail Mechanism of AnQi CMS The thumbnail processing mechanism of AnQi CMS is very user-friendly.

2025-11-08

How to customize the URL alias of the document and ensure the uniqueness of the front-end link?

The custom document URL alias is an indispensable detail in website operation, it not only concerns the SEO performance of the website, but also directly affects user experience and brand image.In AnQiCMS, you have powerful flexibility to manage these aliases and ensure their uniqueness in frontend links. ### Flexibly define, make URLs more meaningful Imagine, which one is easier to remember and share, a chaotic, disordered URL made up of numbers and symbols, or a clear, meaningful URL that directly reflects the theme of the content?

2025-11-08