How to display detailed information of a specific document in the Anqi CMS template, including the title, content, and thumbnail?

Calendar 👁️ 60

In AnQi CMS, sometimes we may need to display detailed information of a preset document at a specific location on the website, such as a recommended area on the homepage or the 'Featured Content' module in the sidebar, including its title, specific content, and eye-catching thumbnail.To achieve this goal, Anqi CMS provides a very flexible and intuitive way.

The Anqi CMS template system uses syntax similar to the Django template engine, which means you can use double curly braces{{ 变量 }}to output data, as well as single curly braces and percent signs{% 标签 %}To execute logical control and call specific functions. This design makes content operation very easy to get started with.

Core Tool:archiveDetailTag

To display detailed information of a specific document in the template, you need to use a one named by AnQi CMSarchiveDetailThe powerful template tag. This tag is specifically used to retrieve and display detailed data of a single document.

UsearchiveDetailWhen labeling, the most critical thing is to tell the system which document you want to retrieve. This can be done in two main ways: through the document ID or through the document's URL alias (tokenIn most cases where it is necessary to specify a document precisely, using the document ID is the most direct and robust method.

Suppose you want to display the title, content, and thumbnail of a document with ID 15 in a template. You can start like this:

{% archiveDetail specificDoc with id="15" %}
    {# 在这里放置显示文档详细信息的代码 #}
{% endarchiveDetail %}

In this code block,specificDocIs a variable name you define, which will carry all the data of the document with ID 15. With this variable, you can easily access the various properties of the document next.

Display the document title

To retrieve the title of the specified document, you just need to accessspecificDocVariableTitlethe property. In the Anqi CMS template, the properties of variables are usually written in camel case.

{% archiveDetail specificDoc with id="15" %}
    <h2 class="document-title">{{ specificDoc.Title }}</h2>
{% endarchiveDetail %}

This code will render the title of the document with ID 15 andh2tags.

display the document content

The content of the document usually includes HTML tags, such as paragraphs, images, links, etc. In order for these HTML contents to be parsed and displayed on the page correctly, rather than being escaped (displayed as source code) as plain text by the browser, you need to use|safefilter.

{% archiveDetail specificDoc with id="15" %}
    <h2 class="document-title">{{ specificDoc.Title }}</h2>
    <div class="document-content">
        {{ specificDoc.Content|safe }}
    </div>
{% endarchiveDetail %}

Add|safeAfter the filter,specificDoc.ContentThe HTML code will be rendered normally by the browser. If the Markdown editor is enabled on the back-end,Contentthe field will also be automatically rendered as HTML,|safeThe filter applies here as well. If you have special requirements and do not want Markdown content to be rendered, you can consider usingarchiveDetailthe tag withrender=falseParameters, but usually, the default rendering is as expected.

Display document thumbnail

In AnQi CMS, the thumbnail of the document usually has two main properties to obtain:LogoandThumb.LogoThe main figure or large image of a document is usually referred to, andThumbIt is a thumbnail processed by the system, which may be smaller and more suitable for displaying in lists or small areas. You can choose one according to your design requirements.

{% archiveDetail specificDoc with id="15" %}
    <h2 class="document-title">{{ specificDoc.Title }}</h2>
    {% if specificDoc.Thumb %} {# 推荐先判断缩略图是否存在 #}
        <div class="document-thumbnail">
            <img src="{{ specificDoc.Thumb }}" alt="{{ specificDoc.Title }}" />
        </div>
    {% endif %}
    <div class="document-content">
        {{ specificDoc.Content|safe }}
    </div>
{% endarchiveDetail %}

In the above code, we added a{% if specificDoc.Thumb %}check, which is a good practice to avoid rendering an empty one without a thumbnailimgLabel to maintain the page structure.

Combine time formatting with custom fields

In addition to the title, content, and thumbnail, you may also want to display the document's publish time, or some custom model fields.A security CMS also provides a convenient way. For example, you can format timestamps usingstampToDateFunction:

{% archiveDetail specificDoc with id="15" %}
    <h2 class="document-title">{{ specificDoc.Title }}</h2>
    <p class="publish-date">发布时间:{{ stampToDate(specificDoc.CreatedTime, "2006年01月02日") }}</p>

    {% if specificDoc.Thumb %}
        <div class="document-thumbnail">
            <img src="{{ specificDoc.Thumb }}" alt="{{ specificDoc.Title }}" />
        </div>
    {% endif %}

    <div class="document-content">
        {{ specificDoc.Content|safe }}
    </div>

    {# 如果您有自定义字段,例如“Author”,可以直接访问 #}
    {% if specificDoc.Author %}
        <p class="document-author">作者:{{ specificDoc.Author }}</p>
    {% endif %}
{% endarchiveDetail %}

By using these simple tags and variable access methods, you can flexibly retrieve and display detailed information of specific documents in any template of AnQi CMS, whether it is used in the recommendation position of the homepage or in a specific content module, it can be easily realized.

Frequently Asked Questions (FAQ)

1. What will the page display if the specified document ID does not exist?IfarchiveDetailTag throughidortokenThen the document specified does not exist in the system,specificDocThe variable will be empty. You can use this in the template to make judgments, for example, using{% if specificDoc %}To enclose the area where the content is displayed. This way, if the document does not exist, the area will not be rendered, avoiding errors or blank content on the page.

2. BesidesidHow can I specify the document to be displayed?In addition to using the document ID (for exampleid="15"), you can also use the document's URL alias (tokenTo specify the document. For example, if a document has a URL alias isabout-us, you can use it like this:{% archiveDetail specificDoc with token="about-us" %}. The choice depends on which identifier is more convenient to obtain during development.

3.specificDoc.LogoandspecificDoc.ThumbWhat is the difference? Which one should I use? specificDoc.LogoIt usually refers to the main image or original image set in the background of the document image, which may be large in size.specificDoc.ThumbThe system generates and crops thumbnails automatically based on the thumbnail size defined in the "Content Settings" on the backend. Use them when displaying small-sized images (such as list items, sidebar recommendations)ThumbCan reduce image loading time, optimize user experience; it may be more suitable to use when displaying large images on document detail pagesLogoSuggest choosing according to the actual display area size and performance requirements.

Related articles

How to create and store a mobile template in Anqi CMS to ensure the normal display of a mobile website?

Build and manage mobile templates in AnQiCMS to ensure your website displays correctly on mobile devices, you need to understand its flexible template adaptation mechanism and clear file storage rules.AnQiCMS provides various mobile adaptation modes, allowing you to choose the most suitable method according to your actual needs. ### Understanding AnQiCMS' Mobile Adaptation Mode Firstly, we need to understand the three main mobile adaptation modes supported by AnQiCMS: 1.

2025-11-07

How to set up a separate display template for specific documents, categories, or single pages in AnQi CMS?

In website operation, we often need to present distinctive design or functional layout for specific content (whether it is detailed documents, entire category pages, or independent single pages).AnQi CMS provides a flexible mechanism that allows users to easily specify independent display templates for this content, thereby achieving highly personalized website display effects. To understand how to set up an independent template, we first need to have a basic understanding of the template mechanism of Anqi CMS.

2025-11-07

How to handle the UTF-8 encoding of Anqi CMS template to avoid garbled display of website content?

When using Anqi CMS to manage website content, you may occasionally encounter situations where乱码 appear on the page, which is usually related to the encoding settings of the template file.The AnQi CMS has specific requirements for the encoding of template files - it must use UTF-8 encoding uniformly.Understanding and properly handling this stage is the key to ensuring that the website content is displayed normally and provides a good browsing experience. Why do character codes appear乱码?

2025-11-07

In Anqi CMS template, how are `{{variable}}` and `{% tags %}` used for displaying dynamic content and logical control?

AnQiCMS with its high efficiency and flexibility has become a good helper for content management.The presentation of website content cannot do without templates, and in the AnQiCMS template system, `{{variable}}` and `{% tag %}` are the core elements for building dynamic pages and realizing powerful functions.They each have different responsibilities, and they collaborate closely to make our website content vibrant. --- ### `{{variable}}`:The intuitive presentation of data Imagine what you want to display on the page, such as the title of an article or the name of a website.

2025-11-07

How to use the `archiveList` tag to flexibly build various document lists and pagination display in Anqi CMS?

Manage and display content is a core operation in Anqi CMS, where the `archiveList` tag plays a crucial role.It can not only help us flexibly present lists of various documents such as articles, products, etc., but also seamlessly connect with the pagination function, meeting various complex content display needs.## Getting to Know the `archiveList` Tag: A Tool for Displaying Content The `archiveList` tag is a core tool in the Anqi CMS template used to retrieve document lists.

2025-11-07

How to use the `archiveFilters` tag to add advanced filtering functionality to the document list of AnQi CMS?

Manage content in Anqi CMS, especially when the website content becomes rich, how to help visitors quickly find the information they need has become the key to improving user experience.If your website offers a diverse range of products or services, or contains a large number of articles with different attributes, then an efficient filtering function will be essential.Today, let's delve into a very useful tag in Anqi CMS, `archiveFilters`, which helps us easily add advanced filtering features to the document list.The foundation of the flexible content model

2025-11-07

How to display the links and titles of the previous and next related articles on the document detail page of Anqi CMS?

In Anqi CMS, adding links and titles of "Previous Article" and "Next Article" to the document detail page is a very practical feature to enhance user experience and content consistency.This not only encourages users to browse more content, but also helps optimize the internal links of the website.AnQi CMS provides simple and efficient template tags, allowing us to easily meet this requirement.

2025-11-07

How to quickly judge whether a string of text in the AnQiCMS template contains specific sensitive words?

In website content operation, compliance and security are of great importance.Especially for platforms with user-generated content (UGC) or when publishing articles, product information, we often need to quickly determine if a string of text contains specific sensitive words.AnQiCMS is an efficient enterprise-level content management system that also provides very flexible and convenient tools at the template level, allowing you to easily meet this requirement.

2025-11-07