AnQiCMS (AnQiCMS) provides great convenience to website operators with its flexibility and powerful content management capabilities. When we carefully create an article or product page and hope to accurately display its colorful content to visitors, archiveDetailTags are an indispensable tool in our hands. They are like a treasure trove of information, allowing us to easily call up all related data of the current content on the article detail page.

In the article detail page template, it is often possible to directly{{archive.字段名}}in the form to call various properties of the current document. Of course, you can also use more explicit{% archiveDetail with name='字段名' %}To retrieve tags, especially when you need to obtain information about a specific document ID. Below, we will delve deeper.archiveDetailThe tag is a commonly used call field on the article detail page, which helps you better understand and apply it.

Content core and SEO optimization

Firstly, let's take a look at the key information that constitutes the basic framework of the content.IdRepresents the unique identifier ID of the document,TitleThe core title of the article or product, these are the most intuitive and most important elements on the page. What is closely related to the title isSeoTitle/KeywordsandDescriptionThey are used to optimize the page title, keywords, and description displayed by search engines, which is crucial for improving the search visibility of the website.

Furthermore,LinkThe field provides a complete access link to the current document andCanonicalUrlIt plays an important role in SEO, indicating to search engines which is the standard version of the content, avoiding duplicate content issues. If you want to point the document to an external resource,OriginUrlCan be used to store the original link.

Main content and visual presentation

ContentThe field is undoubtedly the most important part of the article detail page, carrying all the main content of the article. Anqi CMS provides additional conveniences here, such as supporting image lazy loading, just add it when calling it.lazy="data-src"The properties can be adapted to mainstream lazy loading plugins. What is more impressive is that when you enable the Markdown editor in the background,ContentContent is automatically rendered as HTML, greatly facilitating content creation. If finer control is needed, it can be achieved byrender=true|falsemanually deciding whether to render Markdown through parameters.

For long articles,ContentTitlesThe field is very useful, it can return an array containing the titles of all levels in the article.Developers can easily use this feature to generate the table of contents (TOC) of an article, enhancing the reading experience.

in terms of visual content,Logousually refers to the first image or main image of the document,Thumbwhich is a thumbnail processed by the system. When the document contains multiple illustrations,ImagesThe field will return an array of image URLs, convenient for you to display a beautiful album or gallery through looping.

Content ownership and interactive data

The ownership and associated information of the content is also complete.CategoryIdDisplay the ID of the document category, andCategoryThe field is more powerful, it is a complete category object, from which you can obtain the title, link, description and more detailed information of the category, even including the Logo or thumbnail of the category, helping to build a clear navigation structure.

ModuleIdIt indicates the content model of the document (such as the article model, product model), which is very useful when dealing with different types of content.ParentIdUsed to handle the parent-child relationship of documents, such as the hierarchy of serial articles.

Data related to user interaction is also very important.ViewsDocument views were recorded, which is an important indicator of the popularity of the content.CommentCountIt can display the number of comments the article has received, making it easy for users to understand the interaction热度.FlagThe field is used to identify the recommended attributes of the document, such as "Top Story", "Recommended", etc., for special display in templates.UserIdIt shows the document's publisher ID.

Timestamp and custom extension

CreatedTimeandUpdatedTimeRecorded the creation and update time of the document. These fields return timestamps and need to be配合 in the template.stampToDateLabels need to be formatted in order to be presented in a human-readable date format, for example{{stampToDate(archive.CreatedTime, "2006-01-02 15:04")}}.

For product content,PriceandStockfields are used to display price and stock information.ReadLevelIt can be used to set the document reading permission level.

In addition to these built-in fields, the Anqi CMS content model supports custom fields. This means that if you add additional fields such as "author", "source", etc. in the background for a specific model, these fields can also be accessed througharchive.自定义字段名or{% archiveDetail with name="自定义字段名" %}The way to call it easily, greatly expands the flexibility of content display. When you need to get multiple custom fields, you can use{% archiveParams params %}tags to loop through and display.

In short,archiveDetailThe tag and its rich field list provides highly customized and refined content display capabilities for Anqi CMS users.Whether it is basic text information, complex text and image layouts, or product parameters and user interaction data, they can all be perfectly presented on your website details page through simple tag calls.

Frequently Asked Questions (FAQ)

  1. Why do I use it directly{{archive.Content}}This displays code with HTML tags, not formatted content?This is because the Anqi CMS template engine, for security reasons, defaults to escaping the output HTML content to prevent XSS attacks. If you are sureContentThe HTML code in the field is safe, the browser should be able to parse and display its effect normally, you need to add it when calling|safeFilter, for example{{archive.Content|safe}}.

  2. I am calling in the detail pageCreatedTimeorUpdatedTimeWhy is it showing a string of numbers instead of a date format? CreatedTimeandUpdatedTimeReturns a UNIX timestamp (a string of numbers) and not a direct date and time string. You need to use the built-instampToDatetag to convert it