How to configure a custom display template for the document detail page?

Calendar 👁️ 76

Manage website content in Anqi CMS, flexibility is one of its core advantages.When you need to present a unique content layout or style for a specific document detail page, the system provides a powerful custom template function.This means that you can configure a dedicated display template for the type, content, and even the specific needs of a document, thereby breaking away from the uniformity of traditional CMS and creating more attractive and functional pages.

AnQi CMS is able to achieve this due to its flexible content model design, as well as the continuously enhanced template customization capabilities in system iterations, such as supporting custom category templates, article templates, product templates, and page templates in early versions.These features provide content operators with great freedom, ensuring that the website can adapt to various complex and changing content display needs.

How to specifically configure a custom display template for the document detail page? Anqi CMS provides two main ways for you to flexibly choose according to the actual situation.

Method one: Set a custom template through the document itself

This is the most direct and detailed control method, suitable for when you want a specific document to have a unique display effect.

When you add or edit documents in the background "Content Management", you will notice an option called "Document Template".This is the key to implementing personalized settings. You can enter the name of a template file here, for exampledownload.html. The system will find the corresponding file under the template theme directory you are using to render the details page of this document.

For example, if you have a special type of document on your website, such as a software download page, you may want it to include download buttons, version information, installation guides, and other special layouts. At this point, you can design a special one nameddownload.htmlThe template file, then fill in the 'Document Template' option when publishing this download documentdownload.htmlSo when the user accesses this download document, it will load the carefully designed one you have createddownload.htmlThe template, not the general document detail template.

It should be noted in particular that the template filename you enter must actually exist in your/templateFiles under the directory. If the file does not exist, the document detail page will not display normally.

Method two: Set a unified template through document classification.

If you want all documents under a certain category to use the same specific layout, setting up a document template through the category settings will be a more efficient choice.

In the background "Content Management", enter the editing interface of "Document Classification".Here, you will also find an option for a "document template".Similar to setting for a single document, you can enter the name of a template file here, for exampleproduct_detail_series_A.htmlOnce set and saved, all documents (articles or products) under this category will default to using this specified template to display the detail page.

Moreover, the category template settings provide an option named 'Apply to Subcategories'.If you check this option, the current category and all its subcategories will use the document template you set here.This is very convenient for managing product series or article topics with multi-level hierarchy structures, ensuring consistency in brand image and content experience.

Creating and writing the template file

The prerequisite for configuring a custom template is that you need to create these template files first and write the content within them. All template files should end with.htmland be placed in the current website theme's/templateUnder the directory. The template engine of Anqi CMS supports syntax similar to the Django template engine, users familiar with Django or Blade template syntax will find it easy to get started.

When writing a custom document detail page template, the following steps are usually followed:

  1. Inherit the basic layout:To maintain the consistency of the overall website style, it is recommended that your custom template passes through{% extends 'base.html' %}Inherit your website's basic layout template in this way. This way, you only need to focus on the unique content area of the detail page.
  2. Call document data:The core of a custom template is to display the detailed information of the document. Anqi CMS providesarchiveDetailtags to retrieve all the data of the current document. For example, to display the document title, you can use
    • for example, to display the document title, you can use{% archiveDetail with name="Title" %}.
    • Use to get the document text content{% archiveDetail with name="Content" %}. If the text contains HTML, please be sure to cooperate with it|safea filter such as{{ archiveContent|safe }}To ensure that the HTML content can be parsed by the browser normally rather than as plain text. If the image needs to be lazy-loaded, you can also addlazyproperties such as{% archiveDetail with name="Content" lazy="data-src" %}.
    • other commonly used fields, such as document links (Link), Description (Description), Category (Category) publication time (CreatedTime), Page views (Views), Cover image (Logo) and thumbnail (Thumb), etc., can be accessed througharchiveDetailtags easily.
  3. Display custom fields:If your content model defines additional custom fields, you can usearchiveParamsLabels to retrieve and display them. This allows you to flexibly add and display personalized information for different types of content (such as product parameters, property features, etc.)
  4. Add navigation function:In the document detail page, navigation links for "previous" and "next" articles are often needed. Anqi CMS providesprevArchiveandnextArchivetags to easily implement this feature.

Summary

AnQi CMS provides custom template configurations at the document and category levels, granting content operators great flexibility.Whether it is to create a unique display for a specific document or to unify the style of content under an entire category, these features can help you build a rich content and excellent user experience website.Make full use ofarchiveDetail/archiveParamsetc. core tags, combinedincludeandextendsAuxiliary labels, you will be able to efficiently create and maintain various personalized document detail page templates.


Frequently Asked Questions (FAQ)

Q1: If a document is set with a custom template and also has a document template set for its category, which template will be displayed in the end?

A1: In AnQi CMS, the settings of the document itself have a higher priority than the settings of the category.Therefore, if a document specifies a custom template directly in its editing interface, even if its category is also configured with a document template, the system will ultimately prioritize the template specified by the document itself.This provides you with the most fine-grained control.

Q2: What are the naming restrictions for custom document template files?

A2: Custom template files must be named with.htmlSuffix. The filename itself should follow the operating system's naming conventions, usually it is recommended to use letters, numbers, and underscores, and avoid special characters and spaces.At the same time, to avoid conflicts with the system default template or other files in your current theme, it is best to use a file name with clear identification.Ensure that the template file is located in the current theme's/templatedirectory.

Q3: Why didn't the front page update immediately after I modified the content in the custom template?

A3: This may be due to system caching. Anqi CMS will enable caching mechanisms to improve website access speed.After you modify the template file, you may need to manually clear the system cache for the changes to take effect.You can find the 'Update Cache' feature in the background management interface, click to clear the cache, and then visit the front page again to see the latest effect.In addition, the browser cache may also affect the display, you can try clearing the browser cache or accessing in incognito mode.

Related articles

What sorting methods does AnQi CMS support to display articles and product lists?

How to flexibly display articles and product lists in a content management system is the key to improving user experience and optimizing information architecture.AnQiCMS (AnQiCMS) has provided us with a variety of practical sorting methods in this regard, allowing us to accurately present information based on different business needs and content strategies.### Core Sorting Mechanism: Flexible Control of Content Order AnQi CMS grants us fine-grained control over the display order of articles and product lists through its powerful template tag system

2025-11-08

How to implement article list filtering by category, tag, or recommended attributes?

In website operation, how to efficiently organize and display a large amount of content, and ensure that users can quickly find the information they need, is the key to improving user experience and content value.AnQiCMS (AnQiCMS) provides powerful content management functions, among which the flexible filtering mechanism of the article list can help us easily achieve precise presentation of content.This article will discuss in detail how to filter and display article lists in Anqi CMS through categories, tags, and recommended attributes.--- ### Accurately Present: How to filter and display Anqi CMS article list by category, tag, or recommended attributes

2025-11-08

How to customize the article display form in AnQi CMS based on the content model?

In Anqi CMS, using the content model to flexibly define the display form of articles is one of its core advantages.It can make your website content not limited to traditional 'article' or 'product' formats, but can present diverse content structures according to actual business needs.In the digital world, the content carried by websites is much richer than we imagine.

2025-11-08

How does the AnQiCMS Sitemap tool improve the visibility of a website on search engine results pages?

In today's highly competitive online environment, ensuring that your website content is discovered and displayed at the top of search engine results pages (SERP) is fundamental for enhancing brand visibility and attracting potential users.AnQiCMS (AnQiCMS) is well aware of this as a content management system designed specifically for small and medium-sized enterprises and content operation teams.It comes with a powerful Sitemap tool designed to help users efficiently optimize their websites, thereby significantly improving their visibility in search engines.What is a Sitemap?

2025-11-08

How to set up document thumbnails and control their display on list pages?

In a content management system, a striking thumbnail can greatly enhance the attractiveness of the content, whether it is in an article list, product display, or other content aggregation pages, it is an important visual element to guide users to click.AnQiCMS (AnQiCMS) is well aware of this and provides flexible thumbnail settings and display control features to help optimize the visual effects and user experience of your website.Next, we will discuss in detail how to set the thumbnail of the document in Anqi CMS and master its various display methods on the list page.### The First Part

2025-11-08

How to use the pseudo-static function of AnQi CMS to optimize URL display and improve SEO effect?

In website operation, the URL (Uniform Resource Locator) plays a vital role.A clear, meaningful, and easy-to-understand URL not only improves user experience but is also an indispensable part of search engine optimization (SEO).The traditional dynamic URL often contains parameters and numbers that are difficult to understand, while the pseudo-static URL, through rewriting technology, makes it look as simple and standardized as a static HTML page, thus gaining the favor of search engines and users.AnQiCMS (AnQiCMS) knows the impact of URL structure on website SEO

2025-11-08

How to batch replace keywords or links in the entire site's content and display them immediately?

In website operation, we often encounter situations where we need to adjust a large amount of content, whether it is to adapt to new brand strategies, unify website terminology, fix broken links, or better optimize SEO, these all require batch updating of keywords or links throughout the entire site.Manually modifying one by one not only takes time and effort, but is also prone to errors.The AnqiCMS provides a very practical feature that allows you to easily deal with such challenges: batch replacement of keywords or links in the entire site content, and ensure that changes take effect immediately.This ability is crucial for the daily operation and maintenance of the website

2025-11-08

How to completely remove all tags from HTML content in the AnQiCMS template?

In website content operation, we often encounter such needs: to extract plain text from richly formatted content, such as displaying abstracts on article list pages, or providing clean text for SEO meta description tags.AnQiCMS provides a powerful and flexible template engine, allowing us to easily remove tags from HTML content with built-in filters.

2025-11-08