AutoCMS provides a flexible and powerful template management mechanism, allowing users to specify and display unique templates for documents, categories, and even single pages according to different content types or specific needs.This feature greatly enhances the personalized display capabilities and operational efficiency of the website.

Understanding the meaning of template customization

In website operation, the diversity of content often requires different presentation methods.An in-depth technical article may require a concise and clear layout so that readers can focus on the content itself; a promotional page may need eye-catching visual elements and call-to-action buttons; and a product details page may need to emphasize image display and parameter comparison.By specifying exclusive templates for specific content, we can not only optimize the user experience but also better achieve content operation goals, such as improving conversion rates, enhancing SEO effects, and so on.

AnQiCMS's template system supports two types of file organization modes: folder organization mode and flattened file organization mode, which provides more choices for template developers.At the same time, it is compatible with Django template engine syntax, making the template creation process more user-friendly.

Specify an independent template for a specific document

Imagine that your website has an important download guide, and you want it to have a unique layout with dedicated download buttons and instructions area.This is very direct in AnQiCMS.

When you add or edit a document in the background, you can find a field named 'Document Template' in the 'Other Parameters' section. Here, you can enter the filename of the template you have designed for this specific document, for example,download.html.

To make this setting effective, you need to ensure that the corresponding template file has been created in the directory of the current template theme you are using. For example, if your template theme isdefault, and the document belongs to the 'Article' model, then you can create a file namedarticle/download.html(organized according to the folder pattern) or directly create one in the root directory of the template directorydownload.html(If using flattened mode and configured properly). The system will prioritize the one you specified when rendering this document.download.htmltemplates.

Moreover, AnQiCMS supports some default naming conventions for custom templates, for example, for a document of the article model with ID 10, you can directly name the template file as{模型table}/{文档id}.htmlor{模型table}/detail-{文档ID}.html(such asarticle/detail-10.html),The system will automatically apply without manual specification in the background. This is very convenient for customizing templates for a small number of special documents.

Specify an independent template for a specific category

In addition to individual documents, you may also need to set a uniform display style for all documents (list page) under a certain content category or for the detail page of that category.

In the 'Document Category' management page of the AnQiCMS backend, when editing a category, you can find the 'Category Template' field in 'Other Parameters'. You can specify a custom template file for the list page of this category here, for example,list-news.html.

Similarly, you also need to ensure that the corresponding template file is created under the template theme directory. For example, if your news category belongs to the "article" model, you can createarticle/list-news.htmlWhen the user accesses the list page of this news category, the system will calllist-news.htmlto render the page.

It is worth noting that there is also an option for 'Apply to Subcategories' next to the 'Category Template' setting.If you select this option, all subcategories under this category (if there are no custom templates for the subcategories themselves) will inherit the template settings of the parent category, which is very helpful for maintaining consistency within the category hierarchy.

In addition, there is an option called 'Document Template' in the classification settings. If you want all document detail pages under a specific category to use the same specific template, you can fill it in here, for exampleproduct-detail.htmlThus, all products under this category will be displayed in a unified style without the need to set each document individually. This is particularly useful in scenarios such as product displays and case studies.

System also supports default category template naming conventions, for example,{模型table}/list-{文档分类ID}.htmlIf your template file conforms to this naming, the system will automatically recognize and apply it.

Specify an independent template for a single page

Single-page, such as "About Us

In AnQiCMS, when editing a single page in the 'Page Management', you can also find the 'Single Page Template' field in the form. Here, you can specify an independent template file, such asabout-us.html.

According to the naming conventions of the template file, it can bepage/directory createabout-us.html. When the user visits this single-page, the system will load and useabout-us.htmlto render the content.

It is similar to documents and categories, single-page also supports{单页面id}.htmlThe default naming method, for example,page/detail-1.htmlWill be automatically called by the single page with ID 1.

Key points for naming and storing template files

No matter if you are customizing templates for documents, categories, or single pages, you need to follow the AnQiCMS template file organization conventions:

  1. Root directory: All template files are stored in/templatethe directory.
  2. Subject Folder: Each template theme has an independent folder, for exampledefault.
  3. File Extension: Template files use a unified.htmlsuffix.
  4. Path MatchingThe template name filled in the background should match the relative path and filename under the theme directory of the template file exactly. For example, if you fill in the category templateproduct/custom_list.htmlthentemplate/您的主题/product/The directory should contain a file namedcustom_list.html[en] of the file.

Flexible use of these templates to specify features will make your website content more customizable and better meet the needs of various content operations.

Common Questions (FAQ)

1. Why does the page show an error or cannot be opened when I specify a custom template for the document or category?

This is usually caused by the absence of a custom template file, incorrect path entry, or syntax issues in the template file content.Please first check whether the template file name you filled in the background is completely consistent with the actual template file name you created (including path and file extension).其次,确认该模板文件是否已上传到当前网站主题的正确目录下。Finally, check whether there are any errors in the template file that do not conform to the AnQiCMS template engine syntax, and try using the default template to test whether the web page works normally.

2. I want to set a template for all documents (detail pages) under a certain category at once, rather than setting each document individually. Can AnQiCMS achieve this?

Of course, you can.When editing the category in the category management, you will find a "document template" field.product_detail.html.After saving, all document details pages under this category (unless the document itself is set to a more specific template) will use this template uniformly.This is very efficient when managing a large amount of similar content.

3. AnQiCMS custom template naming has there been any conventions established?

AnQiCMS recommends using the "folder organization mode" to manage templates, for example:

  • Home Page:index/index.htmlorindex.html
  • Model Home Page:{模型table}/index.html(For example}]}article/index.html)
  • Document details page:{模型table}/detail.html(For example}]}article/detail.html)。If you need to specify a specific document template for a particular ID, it can be{模型table}/detail-{文档ID}.html.
  • Document List Page:{模型table}/list.html(For example}]}article/list.html)。List template for a specific category can be{模型table}/list-{文档分类ID}.html.
  • Single Page Detail Page:page/detail.html. Single page template for a specific category can bepage/detail-{单页ID}.htmlorpage/{自定义名称}.html.

Following these conventions helps the system automatically identify and maintain the template structure, and also facilitates team collaboration and future expansion.