In AnQiCMS, setting up independent templates for specific documents, categories, or single pages is a key feature for personalized content display on the website and improving user experience.This not only makes the website design more flexible, but also allows for precise style control for different types of content, thereby better meeting the brand positioning and content operation strategy.
Understanding the template mechanism of AnQiCMS
AnQiCMS provides two main ways to apply custom templates: one is that the system automatically identifies and loads templates based on file naming rules, and the other is to manually specify the template used for a particular content in the background management interface.Both of these methods give content great display freedom, you can choose the most suitable one according to your needs.
AnQiCMS template files are usually named with.htmlwith suffix, and stored uniformly in/templateIn the directory where you use the template theme folder. Template creation follows a syntax similar to the Django template engine, making it easy to get started and convenient for developers or operators to customize.
Configure independent templates for different types of content
1. Set up an independent template for a single page
A single page (such as "About Us",
- Automatic recognition: AnQiCMS has a smart template recognition mechanism. If you create a named folder in the current template theme directory,
page/{单页面ID}.htmlorpage/{单页面别名}.htmlThe file (for example, if your single page ID is 10, then the file name ispage/10.html; if your single page alias is set toabout-us, then the file name ispage/about-us.html),The system will automatically load this template when accessing the single page. This means that as long as the template file exists and the naming follows the rules, it will take effect without any additional settings. - Manually specified:When you want to have more precise control over a single page or when the file naming does not conform to the automatic recognition rules, you can specify it manually from the background. You canPage Resources-u003ePage ManagementEdit the corresponding single page. In the 'Other Parameters' area of the editing interface, find the Single page templateField. Here, you can fill in the template file name you want to use, for example
custom-about.htmlPlease note that this file must exist in the root directory of the template theme you are using, or in a specified subdirectory, for examplepage/custom-about.html. Fill in after, this single page will display the specified template first.
2. Set an independent template for categories.
The uniformity of the style of the category page (such as the article list page, product list page) is crucial for user experience, but sometimes it is also necessary for individual categories to show different styles.
- Automatic recognition (category list page):Similar to a single page, AnQiCMS can automatically load templates based on the category ID. If there is a folder named in your template theme directory named
{模型table}/list-{分类ID}.htmlThe file (for example, the category list page under the article model with ID 1 can be namedarticle/list-1.html), the system will automatically apply this template. - Manually specify (category list page):You canContent Management-u003eDocument CategoryEdit the corresponding category. In the "Other Parameters" area of the category editing page, find the "category template" field. Here you can enter the name of the custom template file, for example
special-category-list.htmlThis template file is usually used to control the layout of the list page under the category.- It is worth mentioning that there is also a “Apply to subcategoryThe option. If you check this, all subcategories under this category (if they do not have their own category template set) will follow this template, which is very convenient for maintaining the uniformity of hierarchical content.
- Specify a template for the documents under the category:In addition to the category list page, you can also find under the category level for this category.All documentsSet a default document template. In the "Other Parameters" area of the category editing page, find theDocument TemplateTemplate file name entered here, for example
special-article-detail.htmlIt will be the default display template for all documents under this category.This means that when a user accesses any document under this category, if the document itself does not specify a template independently, then the document template at this category level will be used.
3. Set an independent template for the document
For certain special articles, product detail pages, you may need them to have a completely unique display style to highlight their importance or characteristics.
- Automatic recognition: The system also supports automatic recognition of document detail pages. If you create a file named under the current template theme directory
{模型table}/{文档ID}.htmlThe file (for example, a document under the article model with ID 100 can be namedarticle/100.html), the system will automatically load this template. - Manually specified:This is the highest priority template setting method. You canContent Management-u003epublish/edit documentsoperate. In the "Other Parameters" area of the document editing interface, find theDocument TemplateField. Here you fill in the name of the template file you want to use, for example
featured-product.htmlOnce a separate template is specified for a document, it will override the document template set at the category level, ensuring that the document is presented in the most unique way possible.
Template file storage location and naming rules review
To better utilize these features, please remember the following key points:
- Root directory:All custom template files should be placed in the current theme folder you are using (for example
/template/default) inside. - Subdirectory:It is recommended to place template files of different content types in the corresponding subdirectories, such as
page/Used for single page,article/or{模型table}/for documents and categorization lists. - Automatically recognize naming format:
- Single page:
page/{单页面ID}.htmlorpage/{单页面别名}.html - Category list page:
{模型table}/list-{分类ID}.html - Document Details Page:
{模型table}/{文档ID}.html
- Single page:
- Manually specify naming:You can freely name the template file (for example
custom-template.html),Then fill in the template field with the corresponding file name in the background. If the template file is in a subdirectory, you need to include the subdirectory path, for examplepage/custom-template.html.
By flexibly using these independent template settings provided by AnQiCMS, you will be able to create a unique visual experience for every part of the website's content, not only making your website more attractive but also better conveying information and achieving more refined content operation goals.
Frequently Asked Questions (FAQ)
Q1: If a document meets both the automatic recognition template naming rules and is manually specified in the background, which one will AnQiCMS prioritize?A1: AnQiCMS will prioritize using the document, category, or single page you set in the backend management interfaceSpecify manuallyThe template. Manually set priorities are highest, they will override the automatically recognized templates, as well as the document templates inherited from the parent category.
Q2: Can I set a uniform template for all documents under a certain category without having to set each document individually?A2: Can do. You can find it in the 'Other Parameters' area when editing categories.Document TemplateThe field. Here you fill in a template filename, all documents in this category (unless the document itself specifies a template) will default to using this template for display.This is very effective for maintaining the style of documents for a specific topic or series.
Q3: If I specify a non-existent custom template file, will the website generate an error? Or how will it display?A3: If you specify a non-existent template file in the background, AnQiCMS will fail to load the template, which usually leads to page display errors or falling back to the system default template (if it exists and logic allows).Therefore, when specifying a custom template, please ensure that the template file has been uploaded and named correctly.