How to display AnQiCMS articles with the `archiveDetail` tag?

Calendar 👁️ 63

When building a rich website in AnQiCMS,archiveDetailThe tag is undoubtedly the core tool for displaying the article detail page. It can flexibly obtain and present all the detailed information of the article or product, helping website operators easily create a detail page that conforms to the brand image and user experience.

archiveDetailThe core role of tags

when visiting a specific article or product page,archiveDetailThe tag comes in handy. It allows you to retrieve all data fields of the current page article, whether it is the title, content, images, or other custom information.It is more convenient that in the article detail page, the system usually automatically provides a name calledarchiveglobal object, allowing you to access{{archive.字段名称}}A concise way to directly access article data without explicitly usingarchiveDetailtags to obtain, greatly simplifying the template code.

Of course, if you need to get the details of a specified article on a non-detail page (such as the homepage or list page), or if you need to get the details of other articles on the detail page,archiveDetailTags can still provide strong support. At this point, you can useid(article ID) ortoken(the URL alias of the article) parameter to specify the article to be retrieved accurately. For example,{% archiveDetail 变量名 with name="Title" id="1" %}You can retrieve the title of the article with ID 1.

Flexibly retrieve all the details of the article.

archiveDetailThe content that can be obtained through tags is very comprehensive, covering all aspects of the article:

  1. Basic Metadata:

    • Title: Article Title.
    • Link: Article Access Link.
    • Description: Article Summary or Description.
    • Keywords: Article Keywords.
    • SeoTitle: Title optimized for search engines.
    • CanonicalUrl: Standard link for SEO, to avoid duplicate content issues.
    • Views: Page views of the article.
    • CommentCount: Number of comments.
  2. Core content and structure:

    • Content: The main content of the article. It is worth mentioning that AnQiCMS supports Markdown editors,ContentThe field can automatically render Markdown syntax into HTML. You can alsolazy="data-src"The parameter enables lazy loading of images in the content, optimizes page loading speed, and allowsrender=true|falsemanual control over whether Markdown is rendered.
    • ContentTitlesAn array that includes information about the titles of various levels in the article content, convenient for generating the table of contents or navigation.
  3. Image resources:

    • LogoThe cover image (large image) of the article.
    • ThumbThe thumbnail of the article.
    • ImagesAn array of image URLs, used to display the group photos or multi-images of an article. Since it is an array, you need to traverse and display it through a loop.
  4. Time information:

    • CreatedTimeThe creation time of the article (Unix timestamp).
    • UpdatedTimeThe update time of the article (Unix timestamp).
    • These two fields need to be coordinated.{{stampToDate(时间戳, "格式")}}tags to format the output, for example{{stampToDate(archive.CreatedTime, "2006年01月02日 15:04")}}The format will be displayed as "2023 August 20 14:30".
  5. Relevant data:

    • Category: The category object of the article, which can be used to directly obtain the category ID, title, and link information. For example{{archive.Category.Title}}. You can also usecategoryDetailtags to obtain more complete category information.
    • Tags: Tags associated with the article. Usually need to be combinedtagListto cyclically display these tags.
  6. Custom field:

    • In the AnQiCMS backend's "Content Model", you can add custom fields for different content models (such as article models, product models). These custom fields can also bearchiveDetailLabel directly access by name, for example{% archiveDetail with name="author" %}. If you want to display all custom fields, you can usearchiveParamslabels for iteration.

Actual application example: build detail page

After understanding these fields, we can easily build the detail page of an article or product.

Example 1: Classic article detail page

On a standard article detail page, you may want to display the article title, category, publish time, associated tags, views, and article content. Below is a concise template code snippet showing how to display these contents:

<article class="article-detail">
    <h1 class="article-title">{% archiveDetail with name="Title" %}</h1> {# 或直接 {{archive.Title}} #}
    <div class="article-meta">
        <span class="category">分类:<a href="{% categoryDetail with name='Link' id=archive.CategoryId %}">{% categoryDetail with name='Title' id=archive.CategoryId %}</a></span>
        <span class="date">发布于:{{stampToDate(archive.CreatedTime, "2006年01月02日")}}</span>
        <span class="tags">标签:
            {% tagList tags with itemId=archive.Id limit="5" %}
                {% for item in tags %}
                    <a href="{{item.Link}}">{{item.Title}}</a>
                {% endfor %}
            {% endtagList %}
        </span>
        <span class="views">阅读量:{% archiveDetail with name="Views" %}</span>
    </div>
    <div class="article-content">
        {% archiveDetail articleContent with name="Content" lazy="data-src" render=true %}
        {{articleContent|safe}} {# |safe 用于避免HTML转义 #}
    </div>
</article>

This code first retrieves the article title. Then, it usescategoryDetailtags to get the link and name of the category. The publish time isstampToDateformatted. Tags are used totagListLabel retrieval and cyclic display. Article contentContentEnabled image lazy loading and rendering Markdown, and using|safeThe filter ensures that HTML content is parsed normally.

Example two: Product detail page, displaying custom parameters

For the product detail page, in addition to the basic information, it may also be necessary to display some unique product parameters (these are usually added as custom fields in the background "content model").

`twig

<div class="product-image">
    <img src="{% archiveDetail with name='Logo' %}" alt="{% archiveDetail with name='Title' %}" />
    {# 如果有组图,可以循环展示 #}
    {% archiveDetail productImages with name="Images" %}
    {% for img in productImages %}
        <img src="{{img}}" alt="{{archive.Title}} - 图{{loop.Counter}}" />
    {% endfor %}
    {% endarchiveDetail %}
</div>
<div class="product-info">

Related articles

How to get and display the document list of the specified category and model in AnQiCMS using the `archiveList` tag?

In Anqi CMS, efficiently managing and displaying website content is the key to improving user experience and search engine rankings.In order to achieve this goal, we often need to organize and display document lists according to specific categories or content models.At this time, the `archiveList` tag has become a powerful tool in our hands.It can help us flexibly extract the required content from the database and present it in a variety of ways.

2025-11-08

How does the `pageDetail` tag display the title, content, and thumbnail of a single page in AnQiCMS?

AnQiCMS provides an efficient way to manage independent pages, such as "About Us", "Contact Information", and so on.These pages usually have independent titles, content, and images, which need to be presented accurately in the front-end template.The `pageDetail` tag is the core tool designed by AnQi CMS to achieve this purpose, allowing us to easily extract and display the detailed information of a single page from the background database.Understanding the `pageDetail` tag: The core of single page content display In AnQiCMS

2025-11-08

How to get and display the list of all single pages of AnQiCMS using the `pageList` tag?

In Anqi CMS, a single page is a very flexible content form that does not rely on complex classification or model structures. It is often used to publish independent and relatively fixed pages such as "About Us", "Contact Information", and "Service Introduction".These pages are characterized by independent content, usually requiring only one page to carry their information.When you need to display a list of single pages at specific locations on a website, such as the bottom navigation, sidebar, or a special topic page, Anqi CMS provides a dedicated `pageList` tag to make this operation simple and intuitive.###

2025-11-08

How does the `categoryDetail` tag display the specific category details of AnQiCMS, such as the introduction or Banner image?

In Anqi CMS template development, effectively displaying detailed category information is the key to improving website user experience and SEO performance.`categoryDetail` tag is born for this, it allows us to flexibly obtain and present various information of specific categories, from basic introduction text to visually stunning Banner images, it can easily handle.### Core Function Analysis: `categoryDetail` Tag Overview The `categoryDetail` tag is mainly used to obtain detailed data for a single category

2025-11-08

How to customize the display layout of the article detail page in AnQiCMS?

In website operation, the article detail page is like the 'face' of the content, it not only carries the core information, but is also a key touchpoint for users to understand deeply and resonate.A well-designed, logically laid out detail page that highlights the value of the content, can significantly enhance the user's reading experience, effectively convey information, and even promote further interaction or conversion.AnQi CMS understands its importance and therefore provides highly flexible and customizable features, allowing us to easily create exclusive article detail pages with unique styles.

2025-11-08

How to achieve multi-language content switching and display in AnQi CMS?

Under the wave of globalization content marketing, website support for multiple languages has become an indispensable function.AnQiCMS (AnQiCMS) understands this need and provides a flexible multilingual solution to help us easily present content to users in different languages.This article will discuss in detail how to implement multi-language content switching and display in Anqi CMS.### Distinguishing System Language and Content Language Before delving deeper, we first need to clarify the concepts of two types of "languages" in Anqi CMS: 1. **System Backend Language Pack:**

2025-11-08

How to take advantage of the pseudo-static function of Anqi CMS to optimize URL display for SEO?

In website operations, a clear and friendly website address (URL) not only improves user experience, but is also an indispensable part of search engine optimization (SEO).The original dynamic URL often contains complex parameters and symbols, which is not very friendly to search engine spiders and user understanding.The pseudo-static feature is exactly to convert these complex dynamic URLs into concise, readable, and static page-like URLs, thus optimizing the website's performance at both the visual and technical levels.

2025-11-08

What website modes (adaptive, PC+Mobile) does AnQi CMS support to display content?

In the era of multi-screen interconnection, how website content adapts to different devices directly affects user experience and the efficiency of information dissemination.AnQi CMS fully considers this requirement, providing users with a variety of flexible website content display modes, ensuring that your website can be presented in **status** on various devices such as PCs, tablets, and mobile phones, bringing visitors a smooth and comfortable browsing experience.The AnQi CMS mainly supports three core modes in content display: adaptive mode, code adaptation mode, and PC+Mobile independent site mode.These three patterns have their own focus

2025-11-08