AnQi CMS provides a flexible and powerful template management mechanism that allows 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 ability and operational efficiency of the website content.

Understanding the significance 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 require prominent visual elements and call-to-action buttons;And a product detail page may need to emphasize picture 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.

The AnQiCMS template system supports two 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 the 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 a dedicated download button and instructions area.This is very direct to implement 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 isdefaultAnd if the document belongs to the "Article" model, you can create a file namedarticle/download.htmlbased on the folder organization pattern, or directly create it in the root directory of the template directorydownload.html(If used in flat mode and configured properly). The system will prioritize the one you specify when rendering this document.download.htmlTemplate.

Moreover, AnQiCMS supports some default custom template naming conventions, for example, for documents 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 be automatically applied 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 a single document, you may also need to set a uniform display style for all documents under a certain content category (list page) or the detail page of that category.

On the AnQiCMS backend "Document Category" management page, when editing a category, you can find the "Category Template" field in the "Other Parameters". Here you can specify a custom template file for the list page of the category, such aslist-news.html.

Similarly, you also need to make sure that the corresponding template file has been created in the theme directory. For example, if your news category belongs to the 'Article' model, you can createarticle/list-news.html. When the user visits the list page of this news category, the system will calllist-news.htmlto render the page.

It is worth noting that next to the "Classification Template" settings, there is also an option for "Apply to Subcategories".If you check this option, all subcategories under this category (if there is no custom template for the subcategory itself) will inherit the template settings of the parent category, which is very helpful for maintaining consistency within the category hierarchy.

In addition, there is also an option for 'Document Template' in the category settings. If you want all document detail pages under a specific category to use the same specific template, you can enter it here, for exampleproduct-detail.html. All products in this category will be displayed in a unified style without the need to set each document individually. This is especially useful in product showcases, case studies, and other scenarios.

The system also supports the default naming convention for category templates, 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 the single page

A single page, such as "About Us", "Contact Information", or various custom landing pages, often also requires unique layouts and styles.

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 convention of the template file, you canpage/Create in the directoryabout-us.html. When the user accesses this single page, the system will load and useabout-us.htmlto render the content

Similar to documents and categories, single pages also support{单页面id}.htmlThe default naming method, for examplepage/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 directoryAll template files are stored in:/templatedirectory.
  2. the theme folderEach template theme has an independent folder, for exampledefault.
  3. file suffixTemplate files are统一 used.htmlAs a suffix.
  4. path matchingThe template name filled in the background should match the relative path and file name under the theme directory of the template file. For example, if you fill in the category templateproduct/custom_list.html, you can betemplate/您的主题/product/Under the directory, there should be a file namedcustom_list.html.

By flexibly using these template-specific features, your website content will present more customization, and better meet the needs of various content operations.

Frequently Asked Questions (FAQ)

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

This is usually due to the absence of a custom template file, an incorrect path entry, or a syntax error in the template file content.Please first check whether the template file name you have filled in the background is exactly the same as the actual template file name you have created (including the path and file extension).Next, confirm that the template file has been uploaded to the correct directory of the current website theme.Finally, check if 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 if the page is working normally.

2. I want to set a uniform template for all documents (detail pages) under a certain category, instead of setting each document individually, can AnQiCMS do that?

Of course you can. When editing the category in the category management, you will find a 'document template' field.Enter the name of the template file you want to use for all document detail pages in this category, for exampleproduct_detail.htmlAfter saving, all document detail 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. What are the conventions for naming custom templates in AnQiCMS?

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

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

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