How to get the detailed information of a specified document, including custom fields, using the `archiveDetail` tag?

Calendar 👁️ 64

In the daily operation of AnQi CMS, obtaining and displaying detailed information of website content is one of the core tasks.archiveDetailThe tag is a powerful tool in the Anqi CMS template system, specifically designed for this purpose, allowing us to flexibly extract detailed data from any specified document, including standard document attributes and user-defined field content.

Deep understandingarchiveDetailThe core function of the tag

archiveDetailTags play a crucial role in Anqi CMS templates, helping website operators display all relevant information for a single document on the page. Whether you want to load the content of the current article on the article detail page, or call data for a specific document on other pages,archiveDetailCan provide concise and efficient solutions.

The basic usage of this tag is usually{% archiveDetail with name="字段名称" %}If the tag does not specify a variable name, it will directly output the value of the requested field.When you need to store the document data you have obtained into a variable for subsequent complex processing or conditional judgment, you can use it in this way:{% archiveDetail archiveItem with name="字段名称" %}Then proceed{{ archiveItem }}to refer to the variable.

To obtain the detailed information of a specific document,archiveDetailThe tag supports the following parameters:

  • id: Specify the document to retrieve by its unique numeric ID. For example,id="1"The document with ID 1 will be retrieved. If this parameter is not specified, the tag will default to trying to retrieve the document associated with the current page.
  • token: By specifying the document URL alias (also known as URL Token) to identify the document. This is very useful when the URL structure is based on aliases. For example,token="my-article-slug". AndidSimilar, if not specified, it will default to the current document.
  • siteIdIn the multi-site management scenario of AnQi CMS, if you need to call document data from other sites, you can specify the site ID through this parameter.In most cases, this parameter does not need to be filled in, the system will automatically identify the current site.

Access the standard fields of the document.

archiveDetailThe tag can directly access multiple built-in standard fields of the document.These fields cover the basic information such as document title, content, links, images, etc.Here are some commonly used standard fields and their usage examples:

  • Document title (Title):{% archiveDetail with name="Title" %}. This will directly display the title of the document.
  • Document link (Link):{% archiveDetail with name="Link" %}. Used to generate the URL pointing to the document detail page.
  • Document description (Description):{% archiveDetail with name="Description" %}. Usually used to display the abstract or introduction of the document.
  • Document content (Content):{% archiveDetail with name="Content" %}. This is the core text content of the document. Please note when using this field.ContentSupportlazyThe parameter is used for lazy loading of images, for examplelazy="data-src"In addition, if the Markdown editor is enabled,Contentthe content will be automatically converted to HTML; you can also userender=trueorrender=falseThe parameter manually controls whether to perform Markdown to HTML conversion. To safely display HTML content, it is usually necessary to combine|safefilter, such as{{ articleContent|safe }}.
  • Document cover first image (Logo) and thumbnail (Thumb):{% archiveDetail with name="Logo" %}or{% archiveDetail with name="Thumb" %}. They retrieve the large image and thumbnail of the document, commonly used for displaying in lists or as the main visual element on the page.
  • Document added time (CreatedTime):{% archiveDetail with name="CreatedTime" format="2006-01-02 15:04" %}. This field returns a timestamp, which needs to be processed throughformatThe parameter specifies the output date and time format.

For example, the basic structure to display the document title and content on the document detail page can be implemented as follows:

<article>
    <h1>{% archiveDetail with name="Title" %}</h1>
    <div class="article-meta">
        <span>发布时间:{% archiveDetail with name="CreatedTime" format="2006-01-02" %}</span>
        <span>浏览量:{% archiveDetail with name="Views" %}</span>
    </div>
    <div class="article-content">
        {% archiveDetail articleContent with name="Content" lazy="data-src" render=true %}
        {{ articleContent|safe }}
    </div>
</article>

Flexiblely obtain custom field content

One of the advantages of AnQi CMS is its flexible content model, which allows operators to define unique custom fields for different types of content (such as articles, products).For example, add fields such as 'color', 'size', 'material', and others to the 'product' model.archiveDetailTags can also retrieve the content of these custom fields.

To get a specific custom field, for example, you have defined a field named in the background.authorThe custom field can be accessed directlynameto call with parameters:

<p>文章作者:{% archiveDetail with name="author" %}</p>

This method is suitable when you exactly know which custom field to call.

You can combine it when you want to dynamically iterate and display all custom fields of the document.archiveParams.archiveParamsThe tag can retrieve all custom parameters of the current document or a specified document and organize them into an iterable array object.

Here is an example of displaying all custom fields.

{% archiveParams params %}
<div class="custom-fields">
    {% for item in params %}
    <p>
        <strong>{{ item.Name }}:</strong>
        <span>{{ item.Value }}</span>
    </p>
    {% endfor %}
</div>
{% endarchiveParams %}

In the above code,paramsIt is througharchiveParamsThe set of custom fields obtained from the tag. EachitemincludeName(field display name) andValue(field value). If your custom field stores an image path, for example, a file namedproduct_galleryThe custom field is used to store the product group image, you can traverse and display the image like this:

{% archiveDetail productGallery with name="product_gallery" %}
{% if productGallery %}
<div class="product-images">
    {% for image in productGallery %}
    <img src="{{ image }}" alt="产品图片">
    {% endfor %}
</div>
{% endif %}

Assuming this hereproduct_galleryThe field type is 'Multiple Image Upload' or 'Multi-line Text' and stores multiple image URLs.In practice, the type of a custom field affects how its value is displayed, so it needs to be handled according to the actual situation in the template.

ByarchiveDetailandarchiveParamsThe tag, AnQi CMS provides powerful content display capabilities for website operators, whether it is standard document information or customized fields for specific business needs, all can be accurately obtained and rendered, greatly enhancing the flexibility and customizability of the website.


Frequently Asked Questions (FAQ)

1.archiveDetailCan the tag retrieve the detailed information of the specified document on the document list page?Yes,archiveDetailThe tag can retrieve the detailed information of the specified document on any page. You just need to go throughidortokenSpecify the parameter to obtain the document clearly. For example,{% archiveDetail with name="Title" id="10" %}You can get the document title with ID 10 on the list page without affecting the loop of the current list.

2. Why do I use{% archiveDetail with name="Content" %}The content retrieved did not display HTML style or Markdown conversion failed? ContentThe field usually retrieves raw text or strings containing HTML tags. If the content contains HTML, you need to use|safeA filter to indicate that the template engine should not escape it, for example{{ archiveContent|safe }}If the content is in Markdown format and you expect it to be automatically converted to HTML, make sure the Markdown editor is enabled in the background content settings, or explicitly add it in the tagrender=trueParameter.

How to determine if a custom field exists or has a value to avoid displaying empty content on the page?When you assign the value of a custom field to a variable, you can useifLogical judgment label to check if the variable exists or is empty. For example, if you have a custom fieldproduct_dimensions:{% archiveDetail dimensions with name="product_dimensions" %} {% if dimensions %} <p>产品尺寸:{{ dimensions }}</p> {% endif %}This ensures that related content is displayed only when the field has a value.

Related articles

How to fetch the document list according to category ID, recommendation attributes, etc. for the `archiveList` tag?

As a senior security CMS website operator, I am well aware that the flexibility and powerful functions of the content management system tags are the key to efficient content operation.`archiveList` tag is the core tool used in AnQiCMS to retrieve document lists. The subtle use of its parameters can help us accurately present the desired content, whether it's building the recommended articles for the homepage, displaying specific documents on category pages, or providing related recommendations on detail pages, all of which rely on our proficiency with this tag.###

2025-11-06

How to use similar Django variable and tag syntax in AnqiCMS templates?

As a senior security CMS website operation personnel, I know the core position of content in the digital age.An efficient content management system, especially its template function, is the foundation to ensure that website content can be presented flexibly and accurately to readers.The AnQi CMS excels in this aspect, drawing on the mature Django template engine syntax, allowing content creators and template developers to build pages in an intuitive and powerful way.### AnQi CMS template engine's Django-style grammar overview AnQi CMS template engine is designed cleverly

2025-11-06

What are the basic conventions and directory structure specifications for AnqiCMS template creation?

Hello! As an experienced AnQiCMS website operator, I am very happy to share with you the key knowledge about AnQiCMS template creation.In my daily work, the reasonable planning and precise application of templates are the foundation for ensuring the efficient display of content and improving user experience.A deep understanding of the basic conventions and directory structure specifications of AnQiCMS templates not only allows us to create and publish content more smoothly, but also lays a solid foundation for the long-term maintenance and optimization of the website. Next

2025-11-06

What are the mainstream search engines supported by AnqiCMS's link push function?

As an experienced website operator, I am well aware of the importance of timely inclusion after content publication for website traffic and SEO performance.AnQiCMS (AnQiCMS) provides many conveniences in content management, among which the link push function is a key factor in helping website content be quickly discovered by search engines.This article will introduce in detail the link push function supported by Anqi CMS, including the main search engine types and their configuration methods, aiming to help website operators better utilize this feature and improve the inclusion efficiency of the website.###

2025-11-06

How to get the category list and detailed information of a single category with the `categoryList` and `categoryDetail` tags?

As a senior AnQi CMS website operation personnel, I know that the flexibility of content organization and presentation is crucial for attracting and retaining users.The site classification structure is not only the skeleton of content, but also an important path for users to explore and discover information.Today, let's delve deeply into the two core template tags in Anqi CMS, `categoryList` and `categoryDetail`, and how they help us efficiently obtain and display category lists and individual category details.## Flexible Construction of Category Navigation: `categoryList`

2025-11-06

How to display all tags and document lists under tags in `tagList` and `tagDataList` tags?

As an experienced website operator who deeply understands the operation of Anqi CMS, I fully understand the core role of content organization and user experience in the success of a website.Tags are the important bridge connecting these two, they not only help us effectively classify and manage a vast amount of content, but also guide users to quickly find the information they are interested in.In Anqi CMS, the `tagList` and `tagDataList` template tags are the key tools to achieve this goal, allowing us to flexibly display tags and associated documents under the tags on the website front-end.###

2025-11-06

How to implement pagination display and style control for document list using the `pagination` tag?

As a website operator who deeply understands the operation of AnQiCMS, I know the subtle art of content presentation lies in how to efficiently and elegantly serve users.For a document list page containing a large amount of content, a reasonable pagination mechanism not only improves user experience but also optimizes website performance.In AnQiCMS, the `pagination` tag is the core tool to achieve this goal, allowing us to flexibly control the pagination display and style of the document list.

2025-11-06

How to format a timestamp to a specified datetime using the `stampToDate` filter in AnqiCMS template?

In the daily operation of AnQi CMS, the precise presentation of content is a key link to improve user experience and website professionalism.The formatting of dates and times is an indispensable part of it.As an experienced website operations manager, I am well aware of the readers' requirements for clear and consistent information.To help everyone better utilize the AnqiCMS template functions, this article will detail how the `stampToDate` filter formats timestamps into specified date and time in AnqiCMS templates.

2025-11-06