In website operations, we often encounter situations where we need to design unique display styles for certain specific pages or content types.Perhaps the product detail page needs a more attractive layout, or a special feature article needs to break the conventional style to highlight its importance, or 'About Us' pages like this one need to showcase the brand characteristics.AnQi CMS deeply understands this personalized need and provides flexible and powerful template customization capabilities, allowing you to easily set exclusive template files for different content, thereby achieving more refined content presentation and brand image management.


Flexible and versatile template application logic

The way Anqi CMS handles template files is both intelligent and intuitive, mainly realized through two mechanisms:Automatic recognition with convention priorityandManual specification on the backend.

1. Contract priority: Intelligent recognition of template files

To simplify operations, Anqi CMS supports a set of 'convention over configuration' rules. If you place template files in a specific naming format, /templateIn the directory, the system can automatically recognize and apply them, without the need for additional configuration on your part. It's like preparing a 'default skin' for specific types of content.

For example, when you want to refer to a certain model (such as the "article" model, whose table name might bearticleWhen a specific document or category has its own list page or detail page, you can try the following naming conventions:

  • Specific template for a single document:You can create a document for a specific ID (e.g., an article with ID 10)article/10.htmlIf this file exists, the system will automatically call it when accessing the article detail page with ID 10.
  • For the list page template under a certain category:If you have a category (such as an article category with ID 123) that requires a special list display, you can createarticle/list-123.htmlWhen the user accesses the list page of this category, the system will use this template first.
  • For a specific template for a single page:For a specific single-page (such as the single-page with ID 5), you can createpage/5.html. The system will automatically apply it when accessing the single-page.

This way, for content with clear IDs or specific categorization rules, you can quickly customize its frontend display without delving into the backend to configure each one individually.

2. Backend specification: Precisely control the display of every piece of content

In addition to automatic recognition, Anqi CMS also provides intuitive backend configuration options, allowing you to precisely specify unique template files for almost all types of content.This method offers greater flexibility and is more suitable for dealing with complex page requirements.

  • Set independent templates for individual documents or products:When you edit a specific article or product, you can find a section named "Other Parameters" on the edit page.Document templateThe field enclosed in quotation marks. Here, you can enter the name of a specific file in the template directory (usually the directory of the current theme you are using), such asdownload.htmlThis means that even if other documents in the same category use the default template, this specific document can have its own unique display style. After filling out, please make sure that thisdownload.htmlThe file actually exists in the template folder of your current topic.

  • Set a template for a category and all its documents:Enter the 'Content Management' under the 'Document Category' page, when editing a category, you will see two fields related to the template:

    • Category Template:This field is used to specify the template used for the list page of this category (for example, the page displaying all articles under this category). By default, it may bemodel/list.html, and you can change it tocategory_promo.htmlCustom templates.
    • Document template:This is a very practical feature. If you want to use the same detail page template for all documents under this category (regardless of new or old), you can fill it in here, for exampleproduct_new_style.htmlIt is also worth mentioning that there is an option called 'Apply to subcategories' here. If checked, this setting will inherit downwards and apply to all subcategories of the current category.
  • Set an independent template for single-page:.Edit any single-page under 'Page Resources' -> 'Page Management', and you will also see a "Single Page TemplateThe field for "". Here, you can specify for "About Us", "Contact Us", etc. single-pageabout_us.htmlorcontact_us_with_map.html[en]With exclusive templates, these static pages can also display rich visual effects and functionality.


Flexible template naming and reference

The template reference mechanism of AnQi CMS is very flexible.Whether you choose to use the convention naming or manually specify it in the background, just make sure that the template file path you fill in the background (relative to the root directory of the current theme template) is accurate, and that the file actually exists.

For example, you can create a file under the theme folderpageTable of contents, and put it inabout.htmlFiles, the content is specifically designed for the "About Us" page. When editing the single page "About Us" in the backend, simply fill in the "Single Page Template" field.page/about.html[en] It is as simple as that. The system will locate and render your exclusive template based on this relative path.


[en] Important usage tips

  1. [en] Ensure that the template file actually exists:No matter how you specify the template, the most critical point is that you must have this file in the corresponding theme template folder on the server.If the file does not exist or the path is incorrect, the page will not display correctly.
  2. [en] Clear naming conventions:Suggest using clear and meaningful names for custom template files, for example,article_featured_detail.htmlorcategory_product_showcase.htmlwhich will help with future maintenance and management.
  3. Take full advantage of template inheritance and fragments:【en】Supports Django template engine syntax, which means you can make use of{% extends 'base.html' %}Perform template inheritance to establish a unified website skeleton; at the same time use{% include 'partial/header.html' %}Introduce reusable code snippets (such as headers, footers, sidebars, etc.). This can greatly improve the efficiency and reusability of template development.
  4. Be sure to test after modification:After changing the template settings, please definitely perform a visit test on the front-end page to ensure everything displays normally.
  5. Understand the priority:In most cases, the most specific settings (such as templates for individual documents) take precedence over less specific settings (such as templates for entire categories).

By the above method, you can easily master the template customization feature of Anqi CMS, whether you are pursuing local highlights under a unified style or creating专题 pages with a completely different style, you can do it with ease.Make your website content more colorful and diverse, providing users with a better browsing experience.


Common Questions and Answers (FAQ)

1. If I set a custom template for a category, will its subcategories inherit this setting?Yes, when you set 'Category Template' or 'Document Template' for the parent category on the category editing page, you can select the option 'Apply to Subcategories'.If checked, this setting will be automatically applied to all subordinate subcategories, greatly simplifying the template management of multi-level categories.

2. Can I set different templates for a single document and its category at the same time? Which one will take effect?In AnQi CMS, the finer the granularity of the settings,