How to call and display the title, content, and related fields of a document on the AnQiCMS article detail page?

Calendar 👁️ 75

In AnQiCMS, the content detail page is the key area where you display core information and attract readers.Effectively call and display the title, content, and various related fields of the document, which can greatly enhance the user experience and richness of the page information.AnQiCMS's powerful template engine provides an intuitive and flexible way to achieve these goals.

Understand AnQiCMS template syntax

AnQiCMS's template system uses syntax similar to the Django template engine, it mainly operates data and logic through two forms:

  • double curly braces{{变量名}}: is used to output the value of a variable.
  • single curly braces and percent signs{% 标签 %}Used to control the logical flow (such as conditional judgments, loops) and call various built-in system functions tags.

On the article detail page, the system will automatically load all the data of the current article into a variable namedarchive. This means that you do not need to perform an additional query and can directly access{{archive.字段名}}the way to access the various properties of the article.

call and display the basic fields of the document.

For the article detail page, calling the basic fields such as title, content, and introduction is usually the most direct need.

Display article title

You can use to display the article title{{archive.Title}}. For example:

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

Display article content

The article content is the core of the detail page. Since the article content usually contains HTML structure (such as rich text editor output), it needs to be used in the output.|safeA filter to ensure that HTML is parsed correctly rather than displayed as plain text.If your content has enabled the Markdown editor, you can also choose whether to render it in the template.

<div class="article-content">
    {# 最常用的方式:确保HTML安全渲染 #}
    {{archive.Content|safe}}

    {# 如果内容可能包含Markdown,并希望在模板中渲染为HTML #}
    {# {{archive.Content|render|safe}} #}

    {# 如果不想渲染Markdown内容,保持原始状态 #}
    {# {{archive.Content|render:false|safe}} #}
</div>

|safeThe filter tells the template engine that this content is safe and does not require HTML entity encoding.|renderThe filter is used to convert Markdown formatted content to HTML.

Display the article summary and keywords

The article summary and keywords can also be accessed directly.archiveRetrieve the corresponding field variable:

<p class="article-description">{{archive.Description}}</p>
<meta name="keywords" content="{{archive.Keywords}}">

Display the image resources of the article

Articles are usually accompanied by thumbnails, cover images, and even image groups. AnQiCMS provides multiple ways to call these images.

Display the cover main image and thumbnail

You can use it to{{archive.Logo}}Get the cover image of the article, by{{archive.Thumb}}Get the thumbnail. These are usually used for the header display of article lists or detail pages:

{% if archive.Logo %}
    <img src="{{archive.Logo}}" alt="{{archive.Title}}" class="article-cover-image">
{% endif %}

{% if archive.Thumb %}
    <img src="{{archive.Thumb}}" alt="{{archive.Title}}" class="article-thumbnail">
{% endif %}

Display the article's group image (multiple images)

If the article is bound to multiple images (as a group image or carousel),archive.Imagesit will return an array of image URLs. You can usefora loop to iterate and display these images:

{% if archive.Images %}
    <div class="article-gallery">
        {% for imageUrl in archive.Images %}
            <img src="{{imageUrl}}" alt="{{archive.Title}} - 图片" class="gallery-item">
        {% endfor %}
    </div>
{% endif %}

Get and display the article's category and tag information

The category and tags of an article are important ways to organize content, displaying them on the detail page can help users better understand the article's ownership and navigate.

Display the category of the article

The category information of the article can be obtained fromarchive.Categorythe object, which includes the title, link and other information of the category.

<p>分类:<a href="{{archive.Category.Link}}">{{archive.Category.Title}}</a></p>

If you need more detailed classification information, such as the description or thumbnail of the category, you can also combinecategoryDetailtags, through theCategoryIdto search:

{% categoryDetail currentCategory with id=archive.CategoryId %}
    <p>分类:<a href="{{currentCategory.Link}}">{{currentCategory.Title}}</a></p>
    <p>分类描述:{{currentCategory.Description}}</p>
{% endcategoryDetail %}

Display related tags of the articles

The tags of the articles can be accessed throughtagListLabel to get. It allows you to specify the retrieval of the current article (viaitemId=archive.Id) all tags, and thenforto loop through and display.

{% tagList tags with itemId=archive.Id limit="10" %}
    {% if tags %}
        <div class="article-tags">
            标签:
            {% for tagItem in tags %}
                <a href="{{tagItem.Link}}" class="tag-link">{{tagItem.Title}}</a>
            {% endfor %}
        </div>
    {% endif %}
{% endtagList %}

call the custom fields of the article

AnQiCMS allows you to define custom fields for different content models to meet the needs of personalized content display. These custom fields can be accessed directly througharchiveVariable field name access, can also be accessed througharchiveParamsLabel traversal display.

Directly access custom fields

If your article model defines a field namedAuthorThe custom field, you can access its value directly as you would with other built-in fields:

<p>作者:{{archive.Author}}</p>

Traversal to display all custom fields

When you want to display all the custom parameters of an article or you are not sure about the specific name of the custom fields, you can usearchiveParamsThe tag. It returns an array object containing all custom field names and values.

{% archiveParams customParams %}
    {% if customParams %}
        <div class="article-custom-fields">
            {% for field in customParams %}
                <p><strong>{{field.Name}}:</strong>{{field.Value}}</p>
            {% endfor %}
        </div>
    {% endif %}
{% endarchiveParams %}

Displays the article's publication time and view count.

This information is very important for providing context to readers and measuring the popularity of the article.

Formatted display of publication/update time

The publication time of the articleCreatedTimeand update timeUpdatedTimeIs timestamp format, needs to be usedstampToDateLabel formatting display:

<p>发布时间:{{stampToDate(archive.CreatedTime, "2006年01月02日 15:04")}}</p>
<p>更新时间:{{stampToDate(archive.UpdatedTime, "2006-01-02 15:04:05")}}</p>

You can also customize the time format according to your needs, for example:2006-01-02/15:04etc.

Display the article view count

The article view count can be accessed through:{{archive.Views}}Directly get:

<p>阅读量:{{archive.Views}} 次</p>

Implement previous and next documents and related articles recommendation

Provide navigation to previous and next documents and related articles at the bottom of the article detail page, which can effectively enhance the depth of users' in-site browsing.

Show the previous and next articles

AnQiCMS providesprevArchiveandnextArchiveTwo tags to get the title and link of the previous and next articles of the current article.

`twig

{% prevArchive prev %}
    {% if prev %}
        <a href="{{prev.Link}}" class="prev-article">上一篇:{{prev.Title}}</a>
    {% else %}
        <span class="prev-article">上一篇:没有了</span>
    {% endif %}
{% endprevArchive %}

{% nextArchive next %}
    {% if next %}
        <a href="{{next.Link}}" class="next-

Related articles

How to use AnQiCMS template tags to retrieve and display the system configuration information of the website?

In Anqi CMS, the system configuration information of the website is the foundation for its operation, including the website name, Logo, filing number, address, and other core data.This information is usually needed to be dynamically displayed on various pages of the website (such as the header, footer, contact us page, etc.) to maintain consistency.To facilitate template developers and content operators to efficiently manage and display this information, AnQiCMS provides a simple and powerful template tag that allows you to flexibly obtain and display the system configuration of the website.Where is the system setting of AnQi CMS? First

2025-11-07

How does AnQiCMS's scheduled publishing function ensure that content is displayed accurately on the website as planned?

In today's fast-paced digital world, the timing of publishing website content is often as important as the content itself.In order to coordinate with market activities, seize hot news, or simply to maintain the regularity of content publication, the ability to accurately control the timing of content going live is crucial.AnQiCMS (AnQiCMS) deeply understands this, and its built-in scheduled publishing function is designed to meet this core requirement, ensuring that your website content is displayed accurately and as planned to visitors.### Say goodbye to manual operation

2025-11-07

How to use AnQiCMS pseudo static and 301 redirect function to optimize URL structure to improve SEO display effect?

In website operation, the structure of URL has a significant impact on search engine optimization (SEO) effectiveness.A clear, concise, and descriptive URL that can improve user experience and help search engines better understand page content, thereby improving crawling efficiency and ranking.AnQiCMS is a powerful content management system that provides comprehensive pseudo-static and 301 redirect functions, helping us create an ideal URL structure.### Understanding SEO-friendly URLs and their importance Imagine that

2025-11-07

How to configure AnQiCMS multilingual support to switch and display content correctly?

AnQiCMS provides powerful multilingual support features, helping us easily promote website content to global users.However, in order to correctly switch and display multilingual content, we need to understand the design approach of AnQiCMS in this regard and configure and manage it through several key steps.It mainly achieves independent content for different language versions by combining "multi-site management", and at the same time provides "default language packages" and "translation tags" to handle the static text in the system built-in text and templates.## Understanding AnQiCMS's multilingual mechanism First

2025-11-07

How to implement custom display templates for category pages in AnQiCMS?

AnQiCMS provides excellent flexibility in website content management, especially when dealing with category page displays. It is not limited to a single fixed layout but allows users to set personalized display templates for category pages based on different business needs and design concepts.This is undoubtedly a very practical feature for operators who hope to improve user experience, strengthen brand image, or optimize specific SEO strategies through differentiated content display.How is it specifically implemented to customize the display template of the category page in AnQiCMS?

2025-11-07

How to correctly display Markdown formatted mathematical formulas and flowcharts in AnQiCMS?

For users who often need to publish technical articles, tutorials, or academic content, the Markdown editor is undoubtedly a tool that improves efficiency.Its concise syntax makes content creation intuitive and quick. AnQiCMS, as a modern content management system, naturally takes full consideration of the use scenarios of Markdown and provides strong support.However, when we need to insert complex mathematical formulas or draw intuitive flowcharts in Markdown-formatted articles, relying solely on the features of Markdown itself is not enough. At this point

2025-11-07

How does AnQiCMS manage and display single-page content, such as 'About Us' or 'Contact Us'?

In website operation, we often need to create some fixed content, large information independent pages, such as "About Us", "Contact Us", "Terms of Service" or "Privacy Policy" and so on.These pages are usually called single-page content, they are an indispensable part of the website, used to provide visitors with core information, build trust, or guide operations.AnQiCMS provides an intuitive and flexible solution for managing and displaying this type of single-page content.

2025-11-07

How to filter and sort articles by category ID and recommendation attributes when displaying the article list in AnQiCMS?

How to effectively organize and present article lists in a content management system is a key factor that directly affects user experience and website information architecture.AnQiCMS provides a flexible and powerful template tag that allows us to refine and sort articles based on category ID and recommended attributes, thereby achieving accurate content placement and optimized display. ### Understanding the `archiveList` article list tag The display of AnQiCMS article lists depends on the `archiveList` template tag.It is like a universal content query tool

2025-11-07