How to configure AnQiCMS so that documents of different categories have independent display templates?

Calendar 👁️ 72

In content management, the diversity of presentation methods is the key to improving user experience and brand image.A website that can present different design styles and information layouts according to different types of content will undoubtedly make it more attractive and professional.AnQiCMS understands this need and provides flexible and powerful template configuration capabilities, allowing us to customize exclusive display templates for different categories and even individual documents.

Next, we will delve into how to configure this feature in AnQiCMS, making your website content shine with unique style.


Understanding the template system of AnQiCMS

In AnQiCMS, template files are the foundation for building the appearance and content layout of a website. They are usually stored with.htmlsuffix and stored in/templateThe directory where you have selected the theme folder. AnQiCMS's template engine syntax is similar to Django, using double curly braces{{变量}}to output data, using single curly braces followed by a percent sign{% 标签 %}Control the logic, such as conditional judgments and loops.

AnQiCMS has a 'convention over configuration' principle in template processing.This means that if you create template files following a specific naming convention, the system can automatically recognize and apply them without any additional settings in the background.For example, for the list page or detail page of a certain content model, the system has a default template path convention.But when we need to implement personalized display for specific categories or documents, we need to break these conventions and manually configure.


Configure exclusive list page templates for different categories

Imagine that your website has two main categories: "news center" and "product showcase".News centerBy customizing the category template, you can easily achieve such differentiation.

1. Prepare your custom template file.

First, you need to create the corresponding template file in the current theme template directory. For example, if you want to create a unique list page for the 'Download Resources' category with ID 5, you can consider the following naming methods:

  • Conventional naming:If the "Download Resources" category belongs to the "Article Model" (model table namearchive), you can create a name calledarchive/list-5.htmlTemplate file. AnQiCMS will try to load this file first when accessing the category list.
  • Custom naming:You can also create a more descriptive filename, such asarticle/download_list.htmlThis method is more flexible, but it requires manual specification in the background.

Whichever method you choose, please make sure that your template file has been uploaded to your AnQiCMS theme folder, for example/template/您的主题名/article/download_list.html.

2. Specify the template for categories in the backend

After the template file is ready, the next step is to apply it to the corresponding category.

  1. Log in to the AnQiCMS backend management interface.
  2. Navigate toContent Managementand then clickDocument Category.
  3. Find the category you want to apply a custom template to (such as “Download Resources”), click the button next toEditbutton.
  4. Scroll down to other parameters in the category editing page.Section.
  5. Incategory templateEnter the name of the template file you just created. If you used a custom name, such asarticle/download_list.htmljust fill inarticle/download_list.html. If you follow the conventional naming convention and want the system to use the file, you can also leave it blank to let the system automatically match; but for clarity, it is also fine to fill it in.
  6. Special reminder:On this page, you will also see oneApply to subcategoryThe option.If this option is checked, all subcategories under the current category (if any) will inherit and use the custom list template you set here, saving the trouble of setting it separately for each subcategory.
  7. ClickConfirmSave changes.

Configure a dedicated detail page template for a specific document

In addition to the category list page, sometimes we also need to provide unique detail displays for certain special documents (such as a detailed product introduction page, a software download page, or an event registration page).

1. Prepare your custom template file.

Similar to the category list page, you need to create a template file for the document detail page in the current theme template directory. For example, if you want to create a dedicated template for a special article, you can name itarticle/special_document_detail.html.

Make sure the file is uploaded to your AnQiCMS theme folder, for example/template/您的主题名/article/special_document_detail.html.

2. Specify the document template in the background

After completing the template file creation, you can assign the template to a specific document using the following steps:

  1. Log in to the AnQiCMS backend management interface.
  2. Navigate toContent Managementand then clickPublish document(For new documents) orDocument Management(For editing existing documents).
  3. On the document edit/publish page, scroll down to.the foldable box.
  4. InDocument TemplateIn the field, enter the custom template filename you have prepared for this document, for examplearticle/special_document_detail.html.
  5. ClickConfirmorPublishSave the document.

In this way, when the user accesses this specific document, AnQiCMS will load and use the custom template you specified, rather than the default detail page template of the category or model.


Combine content model with the use of custom fields

One of AnQiCMS's core advantages is its flexibilityContent modelFunction.Different content models (such as article models, product models) can have independent field settings, and even within the same content model, fields can be further refined through categories.

  • Article modelBelow, the "news" category may only require "title" and "content"; while the "technical article" category may need additional fields such as "author", "publishing platform", etc. custom fields.
  • Product modelUnder the "Electronics

When you customize templates for different categories or documents, these custom fields become particularly important. In custom templates, you can make use of template tags provided by AnQiCMS, such as{% archiveDetail with name="自定义字段名" %}or{% archiveParams params %}To retrieve and display this specific data. This means that your template design can directly focus on these unique fields to achieve highly customized information display.


Practical suggestions and precautions

  • Planning comes first:Before starting to customize the template, it is recommended to clarify the layout and information elements required for different categories or documents, which will help design a more reasonable and reusable template structure.
  • Modular design:Fully utilize the AnQiCMS template'sextends(Template inheritance) andinclude(Introducing code snippet) tag. Extracting common elements such as header, footer, sidebar, etc. can not only reduce duplicate code but also improve maintenance efficiency.
  • Path and naming:Make sure the template filename you enter matches the actual file path and name exactly. The path should be relative to the root directory of your current topic.
  • Test verification:After you configure or modify the template, be sure to clear the AnQiCMS background'sUpdate Cacheand test the access on multiple browsers and devices in the front end to ensure the display effect meets expectations.
  • Version control:If you do a lot of template customization, it is recommended to perform version control on the template files to track modifications and rollbacks.

Through the above configuration, your AnQiCMS website will be able to provide more accurate and personalized display for different types of content, greatly enriching the user experience and bringing more possibilities to website operation.


Frequently Asked Questions (FAQ)

1. Why is my custom template file already uploaded but not found in the "Category Template" or "Document Template" dropdown list in the background?AnQiCMS's 'Category Template' or 'Document Template' field is typically filled in manually, rather than by dropdown selection. You need to ensure that the complete relative path (such asarticle/download_list.htmlEnter into the corresponding text box. Additionally, please confirm that the template file has been correctly uploaded to the current theme being used./templateIt is spelled correctly in the directory.

2. Why do all the document detail pages under the category I have set a custom template still display the default template?The category template mainly controls the display of the *list page* of the category.If you want the *document detail page* under the category to use a custom template, you need to set the 'document template' field additionally on the category editing page, or specify the detail template for each document separately.The document template set in the category will be applied to all documents in the category (if the document itself has not set a specific template).

How to get the current category or current document data in a custom template?In AnQiCMS templates, you can use built-in template tags to retrieve data. For example, to get the title of the current document, you can use{% archiveDetail with name="Title" %}; To get the name of the current category, you can use{% categoryDetail with name="Title" %}. If you have added custom fields in the document content model, you can use{% archiveDetail with name="您的自定义字段名" %}Get its value.

Related articles

How can AnQiCMS effectively prevent malicious scraping and display watermarks on the front end?

Today, with the increasing prosperity of content creation, the value of original content is self-evident, but at the same time, malicious collection and plagiarism have also become a major challenge faced by content creators.It is crucial to choose a CMS with strong security protection to effectively protect the originality and copyright of website content.AnQiCMS is a system specially designed for content operators and provides a comprehensive and practical solution in this aspect.AnQiCMS knows the pain points of content creators, and therefore, from the beginning of system design, it has placed content security and anti-crawling in the core position.The built-in 'Anti-crawling and Watermark Management' function

2025-11-08

How to use AnQiCMS template tags to display detailed information of articles or products?

## How to effectively use AnQiCMS template tags to finely present article and product details In website operations, clearly and comprehensively displaying article and product details is crucial for attracting visitors and conveying core values.AnQiCMS as an efficient and flexible content management system provides powerful and easy-to-understand template tag functions, allowing you to easily present various information entered in the background in a natural and smooth manner on the website front-end.This article will take you in-depth to understand how to use these template tags to display detailed information about articles or products.

2025-11-08

How to implement seamless switching and display of multilingual content in AnQiCMS?

In today's globalized digital world, website multilingual support has become an indispensable part, which not only helps you reach a wider audience and improve user experience, but also effectively optimizes search engine rankings.AnQiCMS (AnQiCMS) fully understands this need and provides flexible and powerful multilingual content management and display functions, allowing your website to easily move towards internationalization.This article will delve into how to seamlessly switch and display multilingual content in Anqi CMS, helping you easily create an internationalized website.

2025-11-08

How to customize the URL structure of AnQiCMS website to improve SEO?

In website operation, the URL (Uniform Resource Locator) plays a crucial role. It is not only the path for users to access website content but also an important basis for search engines to understand and index website information.A clear and semantically friendly URL that can significantly improve the website's search engine optimization (SEO) effect, bringing more natural traffic.AnQiCMS as an efficient and customizable content management system, provides flexible URL structure customization features, helping us easily create SEO-friendly websites.### Understand SEO-friendly URLs

2025-11-08

How to batch replace keywords or links on AnQiCMS website to quickly update displayed content?

In website content operation, timely update and maintenance of content is crucial.Whether it is the unified adjustment of brand keywords or the link failure caused by external changes, manually modifying the content of the entire station one by one is undoubtedly a time-consuming and labor-intensive project.幸运的是,AnQiCMS provides an efficient and powerful feature that can help us easily cope with such challenges: full-site content replacement.This feature allows us to batch update keywords or links on the website, thus quickly and accurately maintaining the unity and timeliness of the website content.To use this convenient feature, we first need to log in

2025-11-08

How to customize the content model in AnQiCMS to achieve diversified content display?

In website operation, the diversity of content is the key to attracting users, enhancing experience, and optimizing search engine rankings.AnQiCMS provides a highly flexible mechanism that allows users to break free from the constraints of traditional content management systems (CMS) such as 'articles', 'products', and other fixed templates. By customizing content models, it can achieve truly diverse content display.Why do we need a custom content model?

2025-11-08

How to make AnQiCMS automatically publish content at a specific time and display it?

In website content operation, maintaining a regular update and release rhythm is the key to attracting and retaining users.However, manually releasing content at specific time points is not only time-consuming but also prone to limitations imposed by human factors.AnQiCMS provides a very practical feature that can help you easily achieve scheduled content release and automatic display, making your website operation more efficient and automated.

2025-11-08

How to set and display the navigation menu of the AnQiCMS website, does it support multi-level structure?

The website navigation is an important guide for users when visiting the website, a clear and easy-to-use navigation menu can greatly enhance the user experience.AnQiCMS offers very flexible and powerful functions in terms of website navigation settings and display, allowing us to easily manage and implement multi-level menu structures to meet the needs of various website layouts.In the AnQiCMS backend, all settings related to website navigation are concentrated in the "Navigation Settings" module.Enter this page, you will first see a "navigation category management" area.This feature is very useful

2025-11-08