How to use AnQiCMS's `archiveDetail` tag to refine the acquisition and display of the detailed content and custom fields of a specified document?

Calendar 👁️ 74

Manage and display website content in AnQiCMS,archiveDetailTags are undoubtedly one of the core tools. They allow us to delve into each specific document, whether it is an article, product, or other custom type, thus extracting and presenting its detailed information, even including those custom fields tailored to business needs.Understand and flexibly apply this tag to make our website content more accurate and rich.

archiveDetailBasic and advanced usage of tags

When we are on a document detail page, AnQiCMS will automatically identify the ID of the current document. At this time, to obtain the title or content of the document, it is usually possible to directly use such as{{archive.Title}}or{{archive.Content}}Such a variable. However,archiveDetailTags provide more powerful control, especially when it is necessary to specify a particular document or to retrieve its specific fields.

UsearchiveDetailThe basic syntax of tags is:{% archiveDetail 变量名 with name="字段名称" %}. The variable name is optional, you can omit it if you directly retrieve and output the content within the tag;But if you want to assign the obtained value to a variable for subsequent reuse or more complex logic processing, specifying a variable name will be very convenient.

Two ways to specify a document: archiveDetailTags are not limited to the current page. If we need to display the content of a specific ID document, or obtain it based on its URL alias (token), we can do so byidortokenTo implement the parameter. For example, if you want to get the ID of1the document title, you can write it like this:{% archiveDetail with name="Title" id="1" %}.

Data call in multi-site environment:For AnQiCMS systems deployed at multiple sites, if you need to call data from other sites in the current site,siteIdParameters come into play. By specifying the ID of the target site, we can retrieve content across sites, which is very useful for resource integration or displaying related content.

Delve into the standard fields of the document

Each document of AnQiCMS includes a series of standard fields such as title, content, link, views, creation time, and so on.archiveDetailLabels allow us to accurately obtain this information one by one.

  • Document title (Title) and description (Description):This is the most basic display element. For example,{% archiveDetail with name="Title" %}Can retrieve the title of the current document.
  • Document content (Content):This is the core part of the document. It is worth noting that if the document content contains HTML tags, in order to ensure that they are parsed correctly by the browser rather than displayed as plain text, we need to use them in conjunction with.|safea filter such as{{archiveContent|safe}}In addition, if your document uses a Markdown editor,ContentThe field supports passing throughrender=truethe parameter is rendered as HTML on the front end, providing a more flexible way to display.
  • Image resources (Logo,Thumb,Images):Documents are usually accompanied by cover images or sets of images.LogoIt usually refers to the first image on the cover,Thumbwhich is a thumbnail, whereasImagesit may be a set of images. When obtainingImagesIt will return an array of image URLs whenforLoop to traverse and display all images.
  • Time information (CreatedTime,UpdatedTime):The creation and update time of the document can clearly show the freshness of the content.archiveDetailTags allow you to go throughformatParameters are formatted directly against the timestamp, for example{% archiveDetail with name="CreatedTime" format="2006-01-02 15:04" %}This allows us to display the date and time in the format we are accustomed to.
  • Views (Views):This is a direct and intuitive indicator of the popularity of content, which can be obtained and displayed to users.
  • Category of the document (Category):ByarchiveDetailThe document object obtained contains detailed information about its category. We can use this information or combinecategoryDetailtags to display category names and links, enhancing the navigation of the content.

Make flexible use of custom fields to create exclusive content display

The strength of AnQiCMS lies in its 'flexible content model' feature, which allows us to customize document fields according to business needs.These custom fields are the key to achieving "fine-grained" content display.

In the background content model settings, we can add various types of custom fields to models such as articles, products, etc., such as "author", "source", "product parameters", "additional albums", and so on. Once these fields are defined and filled with content, we can use them in templates byarchiveDetailtags to get them.

Retrieve all custom fields:If you want to iterate over all custom fields and their values in a document,archiveParamsLabels are an ideal choice. It will return an array object containing field names and values, which we can use to dynamically display throughforcycles, which is very practical in scenarios such as product parameter lists.

{# 假设我们有一个名为'product'的产品模型,其中定义了自定义参数 #}
{% archiveParams params %}
<div>
    {% for item in params %}
    <div>
        <span>{{item.Name}}:</span>
        <span>{{item.Value}}</span>
    </div>
    {% endfor %}
</div>
{% endarchiveParams %}

Accurately retrieve specific custom field:It is more common and flexible to directly obtain the content through the "calling field name" of a custom field (i.e., the lowercase English field name used when defined in the background). For example, if you have customized a field namedauthorThe field can be directly called like this:

<div>作者:{% archiveDetail with name="author" %}</div>

If the custom field is an image group (such as a namedproduct_galleryfield), it will also return an array of URLs that need to be displayed in a loop:

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

Combine an example to create a rich detail page

By combining the above features, we can easily create a detailed document page that is rich in content and clear in structure.

A typical article detail page structure may include:

  • Article title:<h1>{% archiveDetail with name="Title" %}</h1>
  • Publishing information:
    • Category links and names:分类:<a href="{% categoryDetail with name='Link' %}">{% categoryDetail with name='Title' %}</a>
    • Published time:发布于:{% archiveDetail with name="CreatedTime" format="2006年01月02日" %}
    • Views:阅读量:{% archiveDetail with name="Views" %}
    • Tags through related tags:tagListTags cycle to display the tags of the current document.
  • Article content:<div>{% archiveDetail content with name="Content" %}{{content|safe}}</div>

And a product detail page may need:

  • Product main image:<img src="{% archiveDetail with name='Logo' %}" alt="{% archiveDetail with name='Title' %}" />
  • Product name:<h2>{% archiveDetail with name="Title" %}</h2>
  • Product parameters (custom fields): usingarchiveParamsTag loop display all parameters, or accurately call specific parameters such as{% archiveDetail with name="color" %}.
  • Product Introduction:<p>{% archiveDetail with name="Description" %}</p>
  • Product detailed description:<div>{% archiveDetail productContent with name="Content" %}{{productContent|safe}}</div>
  • Contact information: can be combinedcontactTags directly display phone numbers or WeChat and other.

By this means,archiveDetailTags are not only tools for obtaining document content, but also the foundation for the flexible customization and refined operation strategy of AnQiCMS.


Frequently Asked Questions (FAQ)

  1. Can I use it on non-document detail pages?archiveDetailAm I supposed to use the label?Of course you can.archiveDetailOne of the main advantages of tags is their flexibility. As long as you know the ID of the target document or its URL alias (token), you can access it on any page of the website - whether it's the homepage, a list page, or any other single page - byidortokenHow to specify and retrieve the detailed content of a document. For example, to display a complete detail of a 'recommended article' on the homepage, you can specify its ID.

  2. How to ensure passingarchiveDetailThe HTML content obtained (such asContentfield) is displayed safely to avoid XSS risks?AnQiCMS's template engine encodes all output variables by default with HTML entities to prevent XSS attacks. But when you need to display rich text content in the document (such asContentfield), these contents themselves contain HTML tags when|safeThe filter tells the template engine that this part of the content is safe, no encoding is needed, and it can be output directly as HTML.Although this provides flexibility, it also means that you need to ensure that the content entered into these fields is trustworthy, or that strict filtering and validation of user input has been performed on the backend to minimize potential risks.

  3. **If my custom field is a long text but only want

Related articles

How to filter and display content according to different conditions (category, model, recommendation attributes) for the AnQiCMS document list tag `archiveList`?

When building a website with Anq CMS, flexibly displaying content is the key to achieving excellent user experience and efficient content management.Among them, the `archiveList` tag is undoubtedly the core tool for content display, which helps us filter and present articles, products, or other custom content model data according to various conditions.This article will delve into how the `archiveList` tag accurately filters and displays the content you want based on categories, content models, recommendation attributes, and other conditions.

2025-11-08

How to configure the pseudo-static rules in AnQiCMS to optimize the URL structure and improve the display of content in search engines?

The importance of URL structure in a content management system is self-evident.A clear, concise, and meaningful URL not only enhances user experience but is also a key factor in search engine optimization (SEO).In AnQiCMS, by carefully configuring the pseudo-static rules, we can transform those dynamic URLs that may have complex parameters into static forms, thereby allowing the website content to display better in search engines.Understanding URL Rewriting: Why It Is Crucial for Your Website?Imagine, a web page address is `www

2025-11-08

How to customize the AnQiCMS content model to meet the display needs of different content types (such as articles, products)?

In today's rapidly changing digital world, website content is no longer just simple articles or product introductions.In order to accurately reach users and improve conversion rates, we often need to tailor the display form and data structure of different types of content to meet their needs.AnQiCMS (AnQi content management system) fully understands this, and the flexible content model function it provides is a powerful tool to solve this challenge.

2025-11-08

How to correctly use the double curly braces `{{}}` and percentage signs `{% %}` tags in AnQiCMS templates to control the display logic of content?

When using AnQiCMS to build and manage websites, flexibly using template language is the key to improving efficiency and achieving personalized display.Among them, the double curly braces `{{}}` and the percentage tags `{% %}` are two core 'roles' that control the display logic of template files.They each have different responsibilities, understanding and using them correctly can help you easily master the powerful template functions of AnQiCMS.

2025-11-08

In Anqi CMS template, how does the `pluralize` filter convert a single word to plural form?

In AnQi CMS template design, we often need to handle the display of different forms of text based on quantity changes, the most common scenario being the singular and plural form conversion of words.Imagine if your website shows '1 article' and '2 articles s', that is clearly unprofessional.To solve this problem, Anqi CMS provides a very practical `pluralize` filter, which can help us easily implement the conversion of plural forms of words in templates, making the expression more natural and intelligent.

2025-11-08

How to use the `pluralize` filter to generate plural forms of common nouns like `customer`, for example `customers`?

It is crucial to use the singular and plural forms of nouns accurately when presenting content on a website, especially when displaying text related to quantities.A subtle grammatical error, such as using the singular form when the quantity is plural, may affect user experience and even reduce the professionalism of the website content. 幸运的是,AnQiCMS provides a very practical tool——`pluralize` filter, which can help us easily solve this problem in the template, ensuring that the content is dynamic and grammatically correct.

2025-11-08

Does the `pluralize` filter support custom plural suffixes? For example, how do I configure it to convert `cherry` to `cherries`?

In website content operation, the accuracy of content and user experience is crucial.Especially when we need to dynamically adjust the singular and plural forms of words according to the quantity, if we handle it manually, it is not only time-consuming and labor-intensive, but also prone to errors.Fortunately, the AnQiCMS template engine provides very convenient filters to solve such problems, among which the `pluralize` filter is a powerful tool.It can automatically add or adjust plural suffixes for words based on numbers, making your website content more smooth and professional.

2025-11-08

In AnQi CMS, how does the `pluralize` filter correctly display the singular and plural forms of words based on quantity (0, 1, 2, etc.)?

In the world of AnQi CMS templates, dynamic content display is a key factor in improving user experience.When the data on our website involves quantity, how can the relevant words also flexibly show the correct singular or plural form according to the amount, rather than being displayed uniformly, which has become the problem we need to consider.幸运的是,AnQi CMS provides the `pluralize` filter, which can help us easily solve this problem, making your website content more natural and more in line with language habits.## `pluralize` filter

2025-11-08