In AnQiCMS, setting independent templates for specific documents, categories, or single pages is a key feature for personalized content display on the website and enhancing user experience.This not only makes the website design more flexible, but also allows for precise style control for different types of content, thus better meeting the brand positioning and content operation strategy.
Understanding the template mechanism of AnQiCMS
AnQiCMS provides two main methods for applying custom templates: one is that the system automatically identifies and loads templates based on the file naming rules, and the other is to manually specify a template for a piece of content in the background management interface.Both methods provide great flexibility in displaying content, and you can choose the most suitable one according to your needs.
AnQiCMS template files are usually named with.htmlFor suffix, and stored uniformly/templateIn the template theme folder you use under the directory.Template creation follows the syntax similar to Django template engine, easy to learn, and convenient for developers or operators to customize.
Configure independent templates for different types of content
1. Set independent templates for single pages
Single page (such as "About Us
- Automatic recognition:AnQiCMS has a smart template recognition mechanism. If you create a directory named
page/{单页面ID}.htmlorpage/{单页面别名}.htmlThe file (for example, if your single-page ID is 10, the file name ispage/10.htmlIf your single-page alias is set toabout-us, then the file name ispage/about-us.html),系统便会在访问该单页面时自动加载此模板。这意味着只要模板文件存在且命名符合规则,无需额外设置即可生效。 - Manually specify:When you want to have more fine-grained control over a single page, or the file naming does not conform to the automatic recognition rules, you can specify manually through the backend. You can inPage Resources-Page ManagementEditing the corresponding single page. In the "Other Parameters" area of the editing interface, find theSingle Page Templatefield. Here, you can enter the filename of the template you wish to use, such as
custom-about.htmlPlease note that this file must exist in the root directory of the template theme you are currently using, or in the specified subdirectory, for examplepage/custom-about.html. Fill in the form, and this single page will be displayed using the template you specify first.
2. Set an independent template for categories
The consistency of style for classification pages (such as article list pages, product list pages) is crucial for user experience, but sometimes it is also necessary for individual classifications to show different styles.
- 自动识别(分类列表页):类似于单页面,AnQiCMS 可以根据分类 ID 自动加载模板。如果您的模板主题目录下存在名为
{模型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 can inContent management-Document CategoryEdit the corresponding category. In the "Other Parameters" area of the category editing page, find theCategory Templatefield. Here, enter the name of your 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 “Whether to apply to subcategoriesThe option of auto.If you check this option, all subcategories under this category (if they do not have their own category template set separately) will follow this template, which is very convenient for maintaining the uniformity of hierarchical content.
- Specify a template for documents under the category:In addition to the category list page, you can also set the category level for the category under it.All documentsSet a default document template. In the "Other Parameters" area of the category editing page, find the "Document templateEnglish field. Fill in the template file name here, for example
special-article-detail.htmlThis 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, the document template at this category level will be used.
3. Set an independent template for the document
For certain special articles or product detail pages, you may need them to have a completely unique display style to highlight their importance or features.
- Automatic recognition:The system also supports automatic recognition of document detail pages. If you create a file named in the current template theme directory.
{模型table}/{文档ID}.htmlThe file (for example, the document under the article model with ID 100, can be namedarticle/100.html), the system will automatically load this template. - Manually specify:This is the highest priority template setting method. You can operate inContent management-Publish/Edit Document. In the "Other Parameters" area of the document editing interface, find theDocument templateField. Here you enter the template filename you want to use, for example
featured-product.htmlOnce an independent 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.
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 theme folder you are currently using (for example
/template/default). - Subdirectory:It is recommended to place template files for different types of content in corresponding subdirectories,
page/Used for single-page,article/or{模型table}/Used for document and category list. - 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 template files (for example
custom-template.html),Then fill in the template field with the corresponding content in the background. If the template file is in a subdirectory, you need to include the subdirectory path, for examplepage/custom-template.html.
Through the flexible use of these independent template setting functions 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.
Common Questions (FAQ)
Q1: If a document meets both the naming rules of the automatically recognized template and has a template manually specified in the background, which one will AnQiCMS prioritize using?A1: AnQiCMS will prioritize using the document, category, or single page you specify in the backend management interfaceManually specifiedThe template. Manually set priorities are highest, and they override the automatically recognized templates as well as the document templates inherited from the parent category.
Q2: Can I set a unified template for all documents under a category without having to set each document individually?A2: It's okay. You can find it in the "Other Parameters" area when editing categories.Document templateField.Enter a template file name here. 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 on a specific topic or series.
Q3: If I specify a non-existent custom template file, will the website report 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 and usually cause the page to display errors or revert to the system default template (if it exists and the logic allows it).Therefore, when specifying a custom template, please ensure that the template file has been uploaded and named correctly.