How to retrieve the title, content, image, and custom fields of a specific document using the `archiveDetail` tag?

Calendar 👁️ 68

How to use in AnQiCMSarchiveDetailFine control of document content display with tags

AnQiCMS is an efficient and flexible content management system, one of its core advantages lies in its powerful content display capabilities.We hope to be able to finely control the display of each independent article, product details, or any other "document" type of content on the front page of the website. This is exactlyarchiveDetailThe label showcases its talents. It not only helps us obtain the basic information of the document but also easily retrieves associated images, custom fields, and other diverse content, providing rich dynamic display effects for the website.

Get to knowarchiveDetailTag

archiveDetailTags are specifically used to obtain detailed data of a specific document. In most cases, when you visit the details page of a specific document, it will automatically identify the document ID of the current page and load all its information.If you need to display the content of a specific document at a non-detail page or other location, you can also achieve this by specifying parameters.

Its basic usage form is usually like this:{% archiveDetail 变量名称 with name="字段名称" id="1" %}

here,变量名称Is an optional placeholder, if you want to store the data obtained for subsequent more complex processing, you can name it; if not specified, the label will output the field content directly.name="字段名称"This is the key to specify which specific information we want to obtain, andid="1"(Or)token="文档别名")is used to specify which document's data you want to obtain. Usually, you can omit this in the document detail page.idortokenThe system will automatically retrieve the data of the current document.

Display the core information of the document

After understanding the basic syntax, we can start to obtain the core content of the document.

Document Title and Description

The basic requirement is to get the title and description of the document. You can useTitleto get the document title, as well asDescriptionto get the document synopsis.

For example, to display the current document title on the page:<h1>{% archiveDetail with name="Title" %}</h1>

The description is displayed similarly:<p>{% archiveDetail with name="Description" %}</p>

If you want to get the title of a document with a specified ID, you can do it like this:<h2>特定文档标题:{% archiveDetail with name="Title" id="10" %}</h2>

Document content: Handling rich text and Markdown

The document content is the core part of the detail page, usually containing complex HTML structures or Markdown formatted text.archiveDetailByname="Content"To get this part of the data.

Since the content may contain HTML tags, you need to use it in conjunction to ensure that the browser can correctly parse and render these contents|safeFilter. If your document content uses a Markdown editor and you want it to be automatically rendered as HTML, you canContentfield.render=trueParameter.

Example:<div>{% archiveDetail docContent with name="Content" render=true %}{{ docContent|safe }}</div>

In addition, if your website has enabled the image lazy loading feature, you canlazy="data-src"use such parameters to make the system automatically replace images when outputting HTML contentsrcwith a specified attribute name, such asdata-src),convenient for front-end lazy loading script recognition.

Time information: publishing and updating

The publishing and updating time of the document is an important indicator for users to understand the timeliness of the content.archiveDetailProvidedCreatedTime(Add Time) andUpdatedTimeThe field of (update time). These fields return timestamps, and we canformatParameters are formatted directly in the tag, for example, displayed as “2023-10-26”.

Example:<p>发布日期:{% archiveDetail with name="CreatedTime" format="2006-01-02" %}</p> <p>更新时间:{% archiveDetail with name="UpdatedTime" format="2006-01-02 15:04" %}</p>

Flexible display of document images

Images are an indispensable part of the content, AnQiCMS provides various image types for documents:

Cover image and thumbnail

LogoThe field usually represents the cover image of the document,ThumbThe field refers to the thumbnail processed by the system. They can be accessed directly throughnameparameters to obtain the image URL.

Example:<img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" /> <img src="{% archiveDetail with name="Thumb" %}" alt="{% archiveDetail with name="Title" %}" />

multi-image group display

If your document contains multiple images (such as product detail page carousels),ImagesThe field will return an array of image URLs. At this point, you need to define a variable to receive this array and thenforLoop to traverse and display each image.

Example:

{% archiveDetail galleryImages with name="Images" %}
<div class="product-gallery">
  {% for imgUrl in galleryImages %}
    <img src="{{ imgUrl }}" alt="图片描述" />
  {% endfor %}
</div>

Access and display custom fields

AnQiCMS is a highlight with its flexible content model, allowing users to customize various fields for different types of documents.archiveDetailTags also support calling these custom fields.

Suppose you have added a namedMaterial(Material) custom field, or aAuthor(Author) field:

Directly call the custom field

If you know the custom field's调用字段Name (defined in the backend content model), can be directly accessednameparameters.

Example:<p>产品材质:{% archiveDetail with name="Material" %}</p> <p>文章作者:{% archiveDetail with name="Author" %}</p>

Traverse all custom fields

In some cases, you may want to dynamically list all the additional parameters of the document (such as the product specifications list), without knowing the name of each field in advance. In this case, you can usearchiveParamsLabels to retrieve these fields, then display them through a loop.archiveParamsIt will return a list containing field names(Name) and the values of the fields, and you can useValueThe object array.

Example:

<div class="product-specs">
  <h3>产品参数</h3>
  {% archiveParams docParams %}
  {% for param in docParams %}
    <p><span>{{ param.Name }}:</span><span>{{ param.Value }}</span></p>
  {% endfor %}
  {% endarchiveParams %}
</div>

Display combined with associated information

On the document detail page, in addition to the information of the document itself, we usually need to display its category and associated tags.

Display the category information of the document

The category information of the document can be displayed byarchiveDetailofCategoryThe field directly retrieves, it returns a category object, from which you can extract the category ID, title, link, etc.

Example:

{% archiveDetail currentCategory with name="Category" %}
<p>所属分类:<a href="{{ currentCategory.Link }}">{{ currentCategory.Title }}</a></p>

Display document tags

Document tags are usually bytagListLabel retrieval, pass the current document ID as a parameter, and then display through a loop.

Example: “`twig

Tag: {% tagList

Related articles

How to precisely filter and display a document list with specific categories, models, or recommended attributes using the `archiveList` tag?

In AnQi CMS, the `archiveList` tag is the core tool for building dynamic content lists, allowing you to flexibly extract and display the content you want from the website's document library.Whether it is to display the latest articles under a specific category, or popular products under a certain content model, or special document topics with specific recommendation attributes, `archiveList` can help you accurately meet these needs through its rich parameter configuration.### Accurately locate content: Classification, Model and Recommendation Attributes First

2025-11-07

How to dynamically display data using Django-style tags and variables in AnQiCMS templates?

AnQiCMS provides a flexible and powerful template system, which adopts a syntax style similar to the Django template engine, making experienced developers able to get started quickly, and it is also very intuitive, even users who are not familiar with template language can dynamically present website content through simple learning.This system, with its concise labels and variable usage, makes data interaction with the front-end page efficient and easy to manage.To fully utilize the AnQiCMS template for dynamic data display, we need to understand its core syntax structure: variables, tags, and filters

2025-11-07

How to choose and apply the adaptive, code adaptation, PC+mobile terminal template mode supported by AnQiCMS?

How to ensure that the content is presented elegantly and efficiently on various devices when building and operating a website is a challenge that every operator has to face.AnQiCMS as a feature-rich enterprise-level content management system, fully considers this point, and provides three flexible template modes of adaptive, code adaptation, and independent sites for PC and mobile phones, allowing us to make **choices according to actual needs.Next, we will delve into the characteristics, application scenarios, and how to configure and use these three modes in AnQiCMS

2025-11-07

What are the specific conventions for naming template files and directory structures when creating templates in AnQiCMS?

AnQiCMS is a content management system renowned for its efficiency and flexibility, also has a clear set of conventions in template design, aiming to help developers and operators build websites with clear structures and easy maintenance.Understanding these conventions is a key step to efficiently using AnQiCMS for website customization and content display. ### Core conventions of template files The template files of AnQiCMS use the `.html` extension as the suffix.This convention makes the file type clear at a glance and also helps the editor with syntax highlighting and intelligent hints

2025-11-07

How to implement hierarchical display and nested calling of the `categoryList` tag?

Building a clear and organized website navigation in AnQiCMS is crucial for improving user experience and website accessibility, especially when dealing with multi-level categories.The `categoryList` tag was created for this purpose, providing powerful features to help us flexibly display the hierarchical structure of categories and make fine-grained nested calls.

2025-11-07

How to use the `prevArchive` and `nextArchive` tags to navigate to adjacent documents in the article detail page?

In today's content-driven world, the user experience of the website article detail page is particularly important.When a reader is immersed in an excellent content, if they can navigate smoothly to related or adjacent articles, not only can it extend their stay on the website and increase the page views, but it can also indirectly optimize the search engine crawling and ranking through the internal link structure.AnQi CMS is an efficient and SEO-friendly content management system that fully considers these details and provides simple and intuitive template tags to help us easily achieve this function. Today

2025-11-07

How to get and paginate the display of all relevant documents under a specific `tagDataList` tag?

When managing content in Anqi CMS, tags (Tag) are an important tool for organizing and categorizing information.It can not only help users quickly find relevant content, but also significantly improve the internal link structure and SEO performance of the website.When it is necessary to display all relevant documents under a specific tag and to manage pagination, the `tagDataList` tag becomes an indispensable core function.

2025-11-07

How to correctly configure the `pagination` tag to generate a functional pagination navigation on the list page?

In website content management, configuring a fully functional pagination navigation for the list page is a key factor in improving user experience and optimizing the website structure.AnqiCMS (AnqiCMS) provides a simple and powerful `pagination` tag, allowing developers to easily meet this need.To make the `pagination` tag generate the pagination navigation correctly on the list page, it is first necessary to understand its mechanism and the collaborative relationship with content list tags (such as `archiveList`).

2025-11-07