How to get and display the title, content, thumbnail, and publish time on the article or product detail page?

Calendar 👁️ 68

When using AnQi CMS to manage website content, whether it is to publish new articles, update product details, or build list pages, one of the core tasks is to accurately and efficiently display the title, body, thumbnail, and publish time of the content.AnQi CMS provides concise and powerful template tags, making these operations intuitive and easy to understand.This article will provide a detailed introduction on how to flexibly retrieve and present these key information on your website, ensuring that the content display is both beautiful and practical.

Core content retrieval: display of a single article or product page

When you need to display a standalone article or a product detail, the Anqi CMS'sarchiveDetailTags are your preferred tool. This tag is specifically used to extract detailed data of specific content from the database.

Display of title and main contentBasic requirements for obtaining the title and content of the material. In your template file (for example{模型table}/detail.htmlIn it, you can usearchiveDetailtags to obtain directly. For example, the article title can be obtained through{% archiveDetail with name="Title" %}Display. If you want to assign the obtained title to a variable for repeated use elsewhere in the page, you can write{% archiveDetail articleTitle with name="Title" %}{{articleTitle}}. The method of obtaining the main content is similar, using{% archiveDetail with name="Content" %}It can be. Since the text usually contains HTML tags, you may need to cooperate to ensure that the browser correctly parses it.|safeFilter, for example{{archiveContent|safe}}If your text is in Markdown format, you can also make use of it.render=trueParameters are converted, for example{% archiveDetail articleContent with name="Content" render=true %}{{articleContent|safe}}.

Flexible use of thumbnails and imagesThumbnails play an important role in content display. Anqi CMS providesThumbandLogofield to represent the thumbnail of the content.ThumbIt is usually a thumbnail automatically generated by the system, whileLogoit may represent the cover image or the first picture of the content. You can access{% archiveDetail with name="Thumb" %}or{% archiveDetail with name="Logo" %}Get the image address of them. If the content contains a set of images,Imagesthe field will return an array of image URLs, and you can use{% archiveDetail articleImages with name="Images" %}Assign the image array to a variable and then useforLoop to display all images. For example,{% for img in articleImages %}<img src="{{img}}" alt=""/>{% endfor %}.

Accurate presentation of the publish timePublish time (CreatedTimeis an important indicator of content timeliness. The time stored by AnQi CMS is a Unix timestamp, and in order to display it in a human-readable format on the page, we need to usestampToDatefunction.This function is very flexible, allowing you to define the output format according to the Go language time formatting rules.{{stampToDate(archive.CreatedTime, "2006年01月02日")}}; To display hours, minutes, and seconds, it can be set to"2006-01-02 15:04:05".

The content presentation of the list page: Efficient batch acquisition

When displaying an article list, product list, or search results page, we usually need to batch retrieve the titles, abstracts, thumbnails, and publication times of multiple pieces of content. Anqi CMS'sarchiveListThe label can meet this requirement.

Loop traversal and data access archiveListThe tag can be extracted based on your conditions (such as category ID, model ID, limit quantity, etc.). It returns an array object, and you need to useforLoop to iterate over each item. Inside the loop, the title, description, thumbnail, and publish time of each content item (for example, nameditem) can be easily accessed through{{item.Title}}/{{item.Description}}/{{item.Thumb}}and{{item.CreatedTime}}and so on. Easy access.

Date format and image processingSimilar to a single content page, in the list page,item.CreatedTimeSimilarly need to pass throughstampToDateThe function formats the date to ensure clear and easy readability. For thumbnails, you can use{% if item.Thumb %}<img src="{{item.Thumb}}" alt="{{item.Title}}">{% endif %}to determine if the thumbnail exists and display. The description on the list page (DescriptionIt is usually a summary of the text, if it is output directly, it may be too long, at this time, you can consider usingtruncatecharsortruncatewordsfilters to truncate it, for example{{item.Description|truncatechars:100}}to keep the page layout neat.

Summary

The AnQi CMS provides great flexibility and convenience in content acquisition and display. Whether it is handling a single article or product detail page, or building a rich list page, througharchiveDetailandarchiveListThese core tags, combined with field names, time formatting functions, and practical filters, allow you to easily master various content presentation needs.Mastering the use of these tags will make your website content management and front-end display more efficient and professional.


Frequently Asked Questions (FAQ)

1. Why does my article body content display with a lot of HTML tags instead of well-formatted text?This is usually because you haven't used|safeFilter.The AnQi CMS template engine, for security reasons, defaults to escaping all output content with HTML.|safeFilter, for example{{archiveContent|safe}}So that the browser can correctly parse and render HTML.

2. How to set the thumbnail of the article list page to automatically extract the first image from the text when no manual upload is made?Our AQ CMS is built-in with this intelligent function. While you are editing articles or products, if there is no thumbnail uploaded in the "Document Images" field, but the article content is (ContentField) contains images, the system will automatically try to extract the first image in the text as a thumbnail. You just need to use the template.{{item.Thumb}}or{{archive.Thumb}}Call it, the system will automatically handle the priority, first using the manually uploaded thumbnail, and if there is none, it will try to extract the text image.

3. I want to display the publication time of the article, but it shows a string of numbers (timestamp), how can I make it display as a date format?The publication time stored internally in Anqi CMS (for exampleCreatedTime) is a Unix timestamp. To display it as a readable date format on the front-end page, you need to usestampToDateThe function performs the conversion. For example, `{{stampToDate(item.CreatedTime, “2006-0

Related articles

How to optimize the Anqi CMS URL structure to improve the search engine's crawling and display effect?

When we manage our own website content, the link (URL) in the address bar is often a detail that is easily overlooked.However, a clear and organized URL structure not only makes it easier for visitors to understand the content of the page, but also lays the foundation for search engines to effectively crawl and display website information.A good URL can not only improve user experience but also directly affect the performance of a website in search results.AnQiCMS was designed with SEO needs in mind from the beginning, providing rich tools and flexible configuration options

2025-11-08

How to implement multi-language content switching and correct display for different users in AnQi CMS?

Today, with the deepening of globalization, companies and content operators often need to reach users from different language backgrounds.An efficient content management system that can simplify the publishing and management of multilingual content will undoubtedly greatly enhance operational efficiency.AnQiCMS (AnQiCMS) provides a very practical solution at this point, helping users easily switch between languages and display content correctly.### The core concept of AnQiCMS building multilingual websites AnQiCMS regards multilingual support as one of its core features, aiming to help enterprises expand into the international market

2025-11-08

How to get and dynamically display the website name, Logo, and copyright information through template tags?

In AnQiCMS, efficiently managing the core information of a website is the key to building a flexible and easy-to-maintain website.The website name, logo, and copyright statement are an important part of the brand image and legal statement, and they usually need to be consistent across multiple pages of the website.AnqiCMS's powerful template tag system, especially the `system` tag, provides us with a concise and effective way to dynamically retrieve and display this information, greatly enhancing the development efficiency and maintenance convenience of the website.### Understand `system`

2025-11-08

How to ensure that template files do not display乱码 when displayed on the page in AnQi CMS?

When using AnQi CMS to manage website content, if you suddenly find that the text on the page becomes strange and turns into unreadable symbols, which is what we often call 'garbled code', it is undoubtedly very annoying.The root cause of page garbled characters is usually inconsistent file encoding and browser parsing encoding.In Anqi CMS, ensure that template files are displayed normally, avoid garbled text, and the key is to understand and correctly handle the encoding of template files.The AnQi CMS has specific requirements for the encoding of template files, it needs to use **UTF-8 encoding** uniformly

2025-11-08

How to ensure that the content of the article is rendered correctly as HTML on the front-end page if it uses Markdown format?

In Anqi CMS, master Markdown: Ensure content is elegantly rendered as HTML Markdown, as a lightweight markup language, is increasingly favored by content creators for its simplicity, efficiency, and ease of use.It allows us to focus on the content itself without being distracted by complex layout tools.

2025-11-08

How to implement lazy loading of image content on article detail pages to improve page loading speed?

In today's fast-paced online environment, website loading speed is a key factor in user experience and search engine rankings.For an article detail page containing a large number of images, optimizing the image resources is particularly important.By implementing lazy loading of images, we can significantly improve the initial loading speed of the page, allowing visitors to see the content faster, thereby providing a better experience.The AnQiCMS (AnQiCMS) has fully considered the performance optimization needs of the website design, providing a simple and efficient way to achieve lazy loading of images on article detail pages.###

2025-11-08

How to display a list of friend links in the sidebar or footer area of a website?

AnQi CMS provides a set of intuitive and powerful features to help us easily manage website content.Among them, the link to friends is an important part of the external connection of the website, which not only helps the website's SEO performance, but also provides users with more valuable jump links.This article will provide a detailed introduction on how to flexibly display the friend links list in the sidebar or footer area of your website. ### Manage friend links in the background Before displaying the friend links on the website front end, we first need to configure them in the Anqi CMS backend.To manage the friend links, you can log in to the backend

2025-11-08

How to display a list of related articles based on the article's Tag (label)?

In a content management system, effectively utilizing tags (Tag) to organize and associate articles is a key factor in improving user experience and the efficiency of content discovery.AnQiCMS provides a powerful and flexible tag feature, allowing us to easily display related content lists based on the tags of the articles. ## Understanding AnQiCMS Tag Function AnQiCMS Tag function is not just for adding keywords to articles, it is more like a way to associate content across categories and models.By adding tags to the article, we can group those with similar themes

2025-11-08