In website operation, we often encounter situations where we need to design a unique display style for certain pages or content types.Perhaps the product detail page needs a more attractive layout, or some special article needs to break the conventional style to highlight its importance, or a single-page 'About Us' needs to showcase the brand characteristics.AnQi CMS fully understands this personalized demand and provides flexible and powerful template customization capabilities, allowing you to easily set up exclusive template files for different content, thereby achieving more refined content presentation and brand image management.
Flexible and variable template application logic
The way AnQi CMS handles template files is both intelligent and intuitive, mainly through two mechanisms:Automatic recognition with precedence of agreementandManually specified in the background.
1. Priority of convention: Intelligent recognition of template files
In order to simplify the operation, AnQi CMS supports a set of 'agreement first' rules. If you place the template files in accordance with a specific naming format,/templateUnder the directory, the system can automatically recognize and apply them without any additional configuration on your part in the background. This is like preparing a "default skin" for specific types of content.
For example, when you want to use a certain model (such as the "article" model, whose table name may 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 (such as an article with ID 10)
article/10.html. If 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 create
article/list-123.htmlWhen the user visits the list page of this category, the system will prioritize this template. - Specific template for a single page:For a specific single page (such as a single page with ID 5), you can create
page/5.html. The system will automatically apply it when accessing the single page.
In this way, for content with clear IDs or specific categorization rules, you can quickly customize its frontend display without delving deeply into the backend to configure each one individually.
2. Specify in the background: accurately control the display of every content
In addition to automatic recognition, Anqi CMS also provides intuitive backend configuration options, allowing you to accurately specify unique template files for almost all types of content.This method offers more flexibility and is more suitable for dealing with complex page requirements.
Set an independent template for a single document or product:When you edit a specific article or product, you can find a named part calledDocument TemplateThe field. Here, you can fill in the name of a specific file in the template directory (usually the directory of the current theme), such as
download.htmlThis means that even if other documents in the same category use the default template, this particular document can have its own unique display style. Make sure that thisdownload.htmlThe file actually exists in the template folder of your current theme.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 the category (for example, the page displaying all articles under the category). The default may be
model/list.html, and you can change it tocategory_promo.htmlWait for custom template. - Document template:This is a very practical feature. If you want all the documents under this category (new or old) to use the same detail page template, you can fill it in here, for example
product_new_style.html. It is also noteworthy that there is an option to 'Apply to child categories', which, when checked, will inherit the settings downward and apply to all subcategories of the current category.
- Category template:This field is used to specify the template used for the list page of the category (for example, the page displaying all articles under the category). The default may be
Set an independent template for single page:Edit any single page under "Page Resources" -> "Page Management", and there will also be a "Single page templateThe field. Here, you can specify for 'About Us', 'Contact Us' and other single-page websites.
about_us.htmlorcontact_us_with_map.htmlTemplates with exclusive features, thus enabling these static pages to also display rich visual effects and functionality.
Flexible template naming and reference
The template reference mechanism of AnQi CMS is very flexible. Whether you adopt the convention naming or manually specify it on the back-end, you just need to make sure that the path of the template file filled in the back-end (relative to the root directory of the current theme template) is accurate, and the file actually exists.
For example, you can create one under the theme folder.pagecatalog, and place it inabout.htmlThe file contains content specifically designed for the "About Us" page. Then, when editing the "About Us" single page in the background, simply fill in the "Single Page Template" field.page/about.htmlIt is done. The system will locate and render your exclusive template based on this relative path.
Important usage suggestions
- Ensure that the template file actually exists:No matter how you specify the template, the most crucial 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 normally.
- Clear naming conventions:It is recommended to use clear and meaningful names for custom template files, for example
article_featured_detail.htmlorcategory_product_showcase.htmlThis helps with future maintenance and management. - Take full advantage of template inheritance and fragments:The AnQi CMS supports Django template engine syntax, which means you can make use of
{% extends 'base.html' %}template inheritance to establish a unified website skeleton; at the same time, using{% include 'partial/header.html' %}Introduce reusable code snippets (such as headers, footers, sidebars, etc.). This can greatly improve the efficiency and code reuse of template development. - Be sure to test after modification:After each template setting change, please be sure to visit the front-end page for testing to ensure that everything displays normally.
- Understand the priority:In most cases, the most specific settings (such as the template for a single document) take precedence over less specific ones (such as the template for an entire category).
By using the above method, you can easily master the template customization function of Anqi CMS, whether you are pursuing local highlights under a unified style or creating a distinctive special page, you can do so with ease.Let your website content display more vividly, providing users with a better browsing experience.
Frequently Asked Questions (FAQ)
1. Will the custom template I set for a category be inherited by its subcategories?Yes, when you set the "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 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?The finer the granularity set in AnQi CMS,