How to specify and display different templates for specific documents or categories?

Calendar 👁️ 66

AnQi CMS provides a flexible and powerful template management mechanism that allows users to specify and display unique templates for documents, categories, and even single pages according to different content types or specific needs.This feature greatly enhances the personalized display ability and operational efficiency of the website content.

Understanding the significance of template customization

In website operation, the diversity of content often requires different presentation methods.An in-depth technical article may require a concise and clear layout so that readers can focus on the content itself;A promotional page may require prominent visual elements and call-to-action buttons;And a product detail page may need to emphasize picture display and parameter comparison.By specifying exclusive templates for specific content, we can not only optimize the user experience but also better achieve content operation goals, such as improving conversion rates, enhancing SEO effects, and so on.

The AnQiCMS template system supports two file organization modes: folder organization mode and flattened file organization mode, which provides more choices for template developers.At the same time, it is compatible with the Django template engine syntax, making the template creation process more user-friendly.

Specify an independent template for a specific document

Imagine that your website has an important download guide, and you want it to have a unique layout with a dedicated download button and instructions area.This is very direct to implement in AnQiCMS.

When you add or edit a document in the background, you can find a field named "Document Template" in the "Other Parameters" section. Here, you can enter the filename of the template you have designed for this specific document, for example,download.html.

To make this setting effective, you need to ensure that the corresponding template file has been created in the directory of the current template theme you are using. For example, if your template theme isdefaultAnd if the document belongs to the "Article" model, you can create a file namedarticle/download.htmlbased on the folder organization pattern, or directly create it in the root directory of the template directorydownload.html(If used in flat mode and configured properly). The system will prioritize the one you specify when rendering this document.download.htmlTemplate.

Moreover, AnQiCMS supports some default custom template naming conventions, for example, for documents of the article model with ID 10, you can directly name the template file as{模型table}/{文档id}.htmlor{模型table}/detail-{文档ID}.html(such asarticle/detail-10.html), the system will be automatically applied without manual specification in the background. This is very convenient for customizing templates for a small number of special documents.

Specify an independent template for a specific category

In addition to a single document, you may also need to set a uniform display style for all documents under a certain content category (list page) or the detail page of that category.

On the AnQiCMS backend "Document Category" management page, when editing a category, you can find the "Category Template" field in the "Other Parameters". Here you can specify a custom template file for the list page of the category, such aslist-news.html.

Similarly, you also need to make sure that the corresponding template file has been created in the theme directory. For example, if your news category belongs to the 'Article' model, you can createarticle/list-news.html. When the user visits the list page of this news category, the system will calllist-news.htmlto render the page.

It is worth noting that next to the "Classification Template" settings, there is also an option for "Apply to Subcategories".If you check this option, all subcategories under this category (if there is no custom template for the subcategory itself) will inherit the template settings of the parent category, which is very helpful for maintaining consistency within the category hierarchy.

In addition, there is also an option for 'Document Template' in the category settings. If you want all document detail pages under a specific category to use the same specific template, you can enter it here, for exampleproduct-detail.html. All products in this category will be displayed in a unified style without the need to set each document individually. This is especially useful in product showcases, case studies, and other scenarios.

The system also supports the default naming convention for category templates, for example{模型table}/list-{文档分类ID}.htmlIf your template file conforms to this naming, the system will automatically recognize and apply it.

Specify an independent template for the single page

A single page, such as "About Us", "Contact Information", or various custom landing pages, often also requires unique layouts and styles.

In AnQiCMS, when editing a single page in the "Page Management", you can also find the "Single Page Template" field in the form. Here, you can specify an independent template file, such asabout-us.html.

According to the naming convention of the template file, you canpage/Create in the directoryabout-us.html. When the user accesses this single page, the system will load and useabout-us.htmlto render the content

Similar to documents and categories, single pages also support{单页面id}.htmlThe default naming method, for examplepage/detail-1.htmlWill be automatically called by the single page with ID 1.

Key points for naming and storing template files

No matter if you are customizing templates for documents, categories, or single pages, you need to follow the AnQiCMS template file organization conventions:

  1. root directoryAll template files are stored in:/templatedirectory.
  2. the theme folderEach template theme has an independent folder, for exampledefault.
  3. file suffixTemplate files are统一 used.htmlAs a suffix.
  4. path matchingThe template name filled in the background should match the relative path and file name under the theme directory of the template file. For example, if you fill in the category templateproduct/custom_list.html, you can betemplate/您的主题/product/Under the directory, there should be a file namedcustom_list.html.

By flexibly using these template-specific features, your website content will present more customization, and better meet the needs of various content operations.

Frequently Asked Questions (FAQ)

1. Why does the page show an error or cannot be opened when I specify a custom template for a document or category?

This is usually due to the absence of a custom template file, an incorrect path entry, or a syntax error in the template file content.Please first check whether the template file name you have filled in the background is exactly the same as the actual template file name you have created (including the path and file extension).Next, confirm that the template file has been uploaded to the correct directory of the current website theme.Finally, check if there are any errors in the template file that do not conform to the AnQiCMS template engine syntax, and try using the default template to test if the page is working normally.

2. I want to set a uniform template for all documents (detail pages) under a certain category, instead of setting each document individually, can AnQiCMS do that?

Of course you can. When editing the category in the category management, you will find a 'document template' field.Enter the name of the template file you want to use for all document detail pages in this category, for exampleproduct_detail.htmlAfter saving, all document detail pages under this category (unless the document itself is set to a more specific template) will use this template uniformly.This is very efficient when managing a large amount of similar content.

3. What are the conventions for naming custom templates in AnQiCMS?

AnQiCMS recommends using the "folder organization mode" to manage templates, for example:

  • Home:index/index.htmlorindex.html
  • Model homepage:{模型table}/index.html(For example)article/index.html)
  • Document detail page:{模型table}/detail.html(For example)article/detail.html). If you need to specify a particular document template by ID, it can be{模型table}/detail-{文档ID}.html.
  • Document list page:{模型table}/list.html(For example)article/list.html). A list template for a specific category can be{模型table}/list-{文档分类ID}.html.
  • a single page detail page:page/detail.html. A single page template for a specific category can bepage/detail-{单页ID}.htmlorpage/{自定义名称}.html.

Adhering to these conventions helps the system automatically identify and maintain the template structure, and also facilitates team collaboration and future expansion.

Related articles

How to display the page views and comment count of the document?

In website content operation, accurately displaying the document's page views and user comment numbers is a key indicator of the popularity and user activity of the content.AnQiCMS provides flexible and intuitive template tags, helping us easily display these important data in the various corners of the website without delving into complex backend logic.### Show view count and comment number on document detail page When you want to display the current view count and total number of comments on a single document detail page (such as an article, a product detail page), AnQiCMS's

2025-11-07

How to customize the display of thumbnail and cover images for articles or products?

In website content operation, the visual appeal of images is crucial.Whether it is to show the essence of an article or highlight the highlights of a product, a suitable thumbnail and cover image can greatly enhance the user experience and have a positive impact on the spread of content.AnQiCMS (AnQiCMS) offers rich and flexible features, allowing us to easily customize the display of images for articles or products according to specific needs.This article will introduce how to manage and display thumbnails and cover images in AnQi CMS from two aspects: background configuration and template calling.--- ### One

2025-11-07

How to display the list of recommended content related to the current document in AnQi CMS?

When operating a website, we often hope that users can smoothly find more interesting content after reading a wonderful article.This not only extends the user's stay time and reduces the bounce rate, but is also an effective way to enhance the overall value of the website's content and SEO performance.AnQi CMS knows this, and therefore it provides a variety of flexible ways to display the recommended content list related to the current document, helping us better guide users. To implement recommendations for related content, we first need to understand how Anqicms defines 'related'.In system design, "related" can be reflected at several levels

2025-11-07

How to get and display the previous/next content of the current document?

In content-based websites, providing visitors with a convenient navigation experience is crucial, among which the 'Previous' and 'Next' functions are standard features of the article detail page.They can not only guide users to continue browsing more content, effectively increase the website's PV (Page View), but also help search engines better understand the structure of the website's content to optimize SEO performance.AnQiCMS fully considered this requirement, providing us with very simple and intuitive template tags to easily implement this feature.### Learn about AnQiCMS template mechanism At

2025-11-07

How to display extra field data under a custom content model in Anqi CMS?

In AnQi CMS, the flexibility of the content model is one of the highlights of the project, allowing us to create and manage various content structures according to the actual business needs.Whether it is an article, product, event, or any other information that requires a specific field to describe, it can be easily realized through a custom content model.After adding exclusive additional fields to these models, the next step naturally is how to accurately and beautifully display this valuable data on the website front-end.This is not a complex task, Anqi CMS provides intuitive and convenient template tags to complete it

2025-11-07

How to display single page content on the front end of a website (such as About Us, Contact Us)?

In website operation, single-page content like "About Us" and "Contact Us" is indispensable, as it carries important functions such as displaying corporate image, providing contact information, or stating service terms.For friends using AnQiCMS, it is actually a very direct and flexible thing to beautifully display these single-page contents on the website front end. ### Single Page Content Management Overview Firstly, we need to create and manage these single pages in the AnQiCMS backend system.In the left navigation bar of the background, you can find the "Page Resources" menu

2025-11-07

How to display and manage the display of images and video multimedia resources?

In website operation, high-quality multimedia content is the key to attracting visitors and improving user experience.AnQiCMS (AnQiCMS) is well-versed in this, providing comprehensive features to help users easily manage and flexibly display images and videos on their websites.From unified resource library to intelligent optimization settings, AnQiCMS makes multimedia management efficient and convenient. ### One, Core Multimedia Management Center: Image Resource Management Anqi CMS gathers all uploaded images and video resources into a centralized "Image Resource Management" module.This is not only the place where you store your materials

2025-11-08

How to implement the switching display of multilingual website content?

In today's globalized digital environment, making a website support multiple language display is no longer an option, but a necessity for many enterprises and content operators to expand international markets and improve user experience.AnQiCMS (AnQiCMS) took this into consideration from the very beginning, integrating powerful multilingual support features to help us easily switch between different language displays on the website.How can we specifically operate to enable multilingual content switching capabilities for our Anqi CMS website?This can mainly be found in the system language package

2025-11-08