How to display article title, content, images, etc. on the document detail page using the `archiveDetail` tag?

Calendar 👁️ 68

Managing website content in Anqi CMS, the document detail page is undoubtedly the most crucial front for users to obtain information. How to present each meticulously written article, its title, content, images, and various supplementary information accurately and vividly to the user's eyes, this requires the clever use of ourarchiveDetailTagged. This tag is specifically designed to display the details of a single document, and its flexible use will help you easily build a rich and smooth experience details page.

First, let's get to knowarchiveDetailThe core role of the label.When you visit the detail page of a document, Anqi CMS will automatically identify the document information on the current page.archive.字段名This concise way to call the various data of the current document. For example, to display the article title, simply use{{ archive.Title }}It is ready; if you need to display the content of the article,{{ archive.Content }}it can be put into use. This intuitive calling method makes template development extremely easy.

However, if you need to display the details of a specific document on a non-document detail page (such as the homepage or a sidebar of some list page), or need to assign the obtained data to a new variable for more complex processing,archiveDetailThe complete syntax of the tag is particularly important. Its basic usage form is{% archiveDetail 变量名称 with name="字段名称" id="文档ID" %}. Here,变量名称is optional. If you do not set it, the tag will directly output the value of the field.idThe parameter allows you to specify a specific document ID to obtain its information, in addition,tokenThe parameter can also help you find the document accurately through its URL alias.

When building the document detail page, the title and main content of the article are naturally indispensable. You can{{ archive.Title }}to display the article title, through{{ archive.Description }}Display the article summary or description, which is usually used on the page.<title>Tags, SEO keywords, and Meta descriptions. The core part of the article - detailed content, is presented through{{ archive.Content }}Call. An important detail to note is that the content of the article often contains rich HTML tags, in order to ensure that these tags are parsed and displayed correctly by the browser rather than being escaped as plain text, you must in{{ archive.Content }}Add after|safeFilter, that is{{ archive.Content|safe }}. If your article content is written in Markdown editor and you want to render it as HTML on the front end, you canarchiveDetailthe tag withrender=trueparameters, for example{% archiveDetail archiveContent with name="Content" render=true %}{{archiveContent|safe}}.

The image plays a key role in enhancing the visual appeal in content display.archiveDetailTags provide multiple ways to call images.{{ archive.Logo }}It is usually used to obtain the main cover image or lead image of the document, while{{ archive.Thumb }}It is used to obtain the thumbnail processed by the system. If your document is accompanied by multiple images, forming a collection, thenImagesThe field will return an array of image URLs. At this point, you need to combinefora loop to iterate over and display these images, like this:

{% if archive.Images %}
<div class="article-gallery">
    <h3>更多精彩图片</h3>
    {% for imgUrl in archive.Images %}
        <img src="{{ imgUrl }}" alt="{{ archive.Title }}的配图">
    {% endfor %}
</div>
{% endif %}

In addition to the core information mentioned above, AnQi CMS also allows you to add rich metadata and custom fields to documents. For example,{{ archive.CategoryId }}you can obtain the ID of the document's category, and then go through{{ archive.Category.Title }}Retrieve category name,{{ archive.Category.Link }}Retrieve category link, for easy user navigation. Article publish time{{ archive.CreatedTime }}and update time{{ archive.UpdatedTime }}stored in timestamp format, you can usestampToDateThe function formats it into an easily readable date format such as{{ stampToDate(archive.CreatedTime, "2006年01月02日 15:04") }}。“Furthermore,”{{ archive.Views }}It can intuitively display the number of views of the article.

Although the tags (Tag) of the document,archiveThe object does not directly contain a list of labels, but you can combinetagListlabels to get all associated labels with the current document, and thenfordisplay them in a loop:

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

The strength of AnQi CMS also lies in its flexible content model, which allows you to customize exclusive fields for different types of documents (such as articles, products). These custom fields can be accessed directly through{{ archive.您的自定义字段名 }}The way to call. For example, if you define a product modelPricefield directly{{ archive.Price }}It can. If the content of the custom field may also contain HTML, you also need to add|safeFilter. If you are not sure about the custom fields or want to dynamically display all custom fields, you can usearchiveParamstags to iterate through them:

<div class="article-custom-fields">
    <h3>附加信息</h3>
    {% archiveParams params %}
        {% for item in params %}
            <p><strong>{{ item.Name }}:</strong>{{ item.Value|safe }}</p>
        {% endfor %}
    {% endarchiveParams %}
</div>

By combining these tags, you can build a document detail page that is both beautiful and practical, whether it's displaying an in-depth article or a featured product, you can do it with ease.


Frequently Asked Questions (FAQ)

  1. Why do I use{{ archive.Content }}When calling the content of the article, why does the page display the original text with HTML tags, rather than the rendered effect?
    • Answer:This is because the Anqi CMS template engine, for security reasons, defaults to escaping all output content to prevent XSS attacks. If your article content contains HTML tags and you want them to be normally parsed by the browser, be sure to{{ archive.Content }}Add after|safeFilter, that is{{ archive.Content|safe }}.

2

Related articles

How does the `archiveList` tag display the article list based on categories, recommended attributes, or custom sorting?

In the Anqi CMS template system, the `archiveList` tag is the core tool for building dynamic content lists.Whether it is a blog article list, product display page, or news information module, `archiveList` can help you accurately filter, sort, and present content according to your diverse needs, bringing vitality to your website content area.

2025-11-08

How are the `pageList` and `pageDetail` tags used to display single-page content such as 'About Us'?

In website operation, content such as 'About Us', 'Contact Information', or 'Service Introduction' usually exists as independent pages, which we call 'single pages'.They do not update as frequently as blog posts, but they are essential core information for the website.AnQi CMS provides the `pageList` and `pageDetail` tags, allowing you to manage and display these single-page contents flexibly and efficiently.

2025-11-08

How to retrieve and display the name, description, and thumbnail of a specific category?

In website operations, clearly and effectively displaying classification information is crucial for user experience and search engine optimization.A specific category name can help users quickly understand the content theme, a concise description can provide more background information, and a direct thumbnail can attract users to click.AnQiCMS (AnQiCMS) provides a powerful and flexible template tag feature, allowing you to easily obtain and present these key classification information, whether it is to build a navigation menu, design a category list page, or optimize search engine results.###

2025-11-08

How to use the `categoryList` tag to display the list of articles/products categories on the homepage or sidebar?

When building and optimizing a website, a clear navigation structure is crucial for user experience and search engine optimization.AnQiCMS (AnQiCMS) provides us with powerful template tags, among which the `categoryList` tag is a core tool used to flexibly display article or product category lists on the homepage or sidebar of the website.With it, we can easily organize the content of the website neatly, allowing visitors to find the information they are interested in at a glance.Why is the category list so important? Imagine when visitors come to a rich content website

2025-11-08

How to implement the previous/next document function using `prevArchive` and `nextArchive` tags?

When you operate a website, providing a smooth reading experience for users is one of the key factors in enhancing website stickiness.When a user finishes reading a document, if they can easily jump to the previous or next related article, it will undoubtedly greatly increase their stay time on your website.AnQiCMS (AnQiCMS) understands this and provides very intuitive and powerful `prevArchive` and `nextArchive` tags to help you easily implement this feature.

2025-11-08

How to use the `archiveList` tag's `type="related"` feature to display related article recommendations?

On your website, when visitors finish reading an article, if they can see related content in time, it not only can significantly improve the user experience, reduce the bounce rate, but also can effectively increase the page views and stay time on the website.AnQi CMS provides a very convenient tag: `archiveList`,配合其`type="related"` attribute, it can easily realize this function.###

2025-11-08

How does the `archiveParams` tag display custom field data of the document on the frontend page?

In AnQi CMS, the flexibility of content is one of our core advantages for website operation and content management.In addition to standardized fields such as titles and text, we often need to add specific custom information for different types of content, such as the 'brand', 'model', and 'origin' of products, or the 'author' and 'source' of articles, etc.These custom fields greatly enrich the dimensions of content display, but how to accurately and flexibly present these meticulously entered backend data on the front-end page is an important consideration during template development. At this time

2025-11-08

How to build a complex search interface for product filtering or property filtering using the `archiveFilters` tag?

In the era of content explosion, when users visit websites, they often hope to quickly find the content they are interested in.Whether it is browsing a large number of products on e-commerce platforms or looking for housing that meets your preferences on real estate websites, a powerful and easy-to-use filtering and search interface is the key to improving user experience. AnQiCMS (AnQiCMS) knows this and provides a powerful `archiveFilters` tag for this purpose.This tag can help you easily build a complex product or property filtering interface, making your website content more discoverable and interactive

2025-11-08