In content operation, creating unique visual and functional experiences for different parts of the website is crucial for enhancing brand image, optimizing user experience, and accurately conveying information.AnQiCMS (AnQiCMS) knows this well, providing flexible template customization capabilities, allowing us to set personalized display templates for specific articles, categories, or even independent single pages, thus achieving differentiated content presentation.
The core of this feature lies in the ability to break free from the limitations of website global templates, and to design and apply specific layouts or styles targetedly to better match content themes or operational objectives.For example, an important promotional article may require an eye-catching full-screen layout, a product category page may need a specific product display card layout, and a single "About Us" page may require a concise and professional introduction template.
AnQi CMS template mechanism overview
The template system of Anqi CMS is based on a template engine syntax similar to Django, using.htmlfiles as the template carrier, and uniformly stored in the root directory of the website,/templateFolder. Each website theme has its own template directory, for example/template/default/. This structure is clear and easy to manage, laying a foundation for our subsequent personalized template settings.
To implement personalized content display, there are mainly two ways: one is to use the template naming rules built into the AIT CMS to allow the system to automatically recognize and apply; the other is to manually specify the template file for the content in the background.
第一种方式:利用内置的模板命名规则(English应用)
The Anqi CMS has a set of intelligent template search mechanisms.If we create template files according to specific naming conventions, the system will automatically apply them to the corresponding content without any additional settings.This provides great convenience for some common personalized needs.
以下是安企CMS支持的默认自定义模板命名格式:
- Document (article/product) details page:
{模型table}/{文档id}.html例如,如果你的文章模型表名为article,有一篇文章的ID是123,那么你可以创建一个名为article/123.html的模板文件。当访问这篇文章时,系统将自动使用这个模板。 - Document list page (category page):
{模型table}/list-{分类id}.html同样,对于ID为5的文章分类,你可以创建一个article/list-5.html的模板,系统便会用它来渲染该分类的文章列表页。 - Single Page Details Page:
page/{单页面id}.html如果有一个单页面ID是10,那么创建page/10.htmlIt can achieve automatic application.
Further, we can also use custom URL aliases to name template files, making the template names more readable. For example, if the custom URL alias for the single page "About Us" isabout-us, then you can create onepage/about-us.htmlA template will be automatically applied by the system.
The second way: manually specify the template via the background (flexible customization)
When our personalized needs cannot be met by naming rules or when we want to have more precise control over template application, AnQi CMS allows us to directly specify template files for articles, categories, or single pages in the background.
We need to create our customized template file in the directory of the current theme we are using before making any background settings..htmlFor example, if you are usingdefaultSubject, you can find/template/default/create a directory underspecial-article.htmlorproduct-promo.htmlin these files.
Next, we will introduce how to manually specify by content type:
For a single article or product:
- Login to the AQ CMS backend, navigate to the "Content Management
- Find the article or product you want to apply a custom template to, and click the "Edit" button on the right.
- At the bottom of the editing page, there is usually a field named "Document Template".
- Enter the custom template filename you created in this field, for example
special-article.htmlPlease only enter the filename, without including the path or file extension. - After saving changes, the article or product will use the one you specified when accessed on the frontend
special-article.htmlto display the template.
For specific categories and their sub-documents:The 'AnQi CMS' provides two levels of granularity in category template settings:
- Category list page template:
- Navigate to the 'Content Management' module in the background and select 'Document Category'.
- Find the category you want to apply a custom template to, and click the 'Edit' button on the right.
- In the edit page, there is a field named "Classification Template". This template is usually used to render the list page of the classification, such as
list-with-sidebar.html. - Here you can also select the option 'Apply to subcategories'. If selected, all subcategories under this category will inherit this template setting.
- Template for category articles/products detail page:
- In the same category editing page, there is also a 'Document Template' field.
- This field allows you to add for the category underall articles or product detail pagesSpecify a template uniformly. For example, if you want all products in a certain product category to use
product-detail-v2.htmlto display, you can fill it in here. - This setting is also affected by the 'Apply to subcategories' option, if checked, the documents under the subcategories will inherit this template.
Through these two templates, we can achieve dual personalized control over the category page and its document detail page.
- Category list page template:
For single-page:
- Login to the AnQi CMS backend, navigate to the "Page Resources
- Find the single page you want to apply a custom template to, and click the 'Edit' button on the right.
- At the bottom of the editing page, there will be a field named 'Single Page Template'.
- Enter the custom template filename you created in this field, for example
about-us-style.html. - Save changes after, the single page will use the one you specified when accessed in the front-end
about-us-style.htmlto display the template.
Placement and structure of the template file
All custom template files should be placed in the theme directory you are currently using. For example, if your theme folder isdefault, then the path to your template file should be/template/default/You can directly place this directory.special-article.htmlYou can also create subdirectories based on content models or other logic, such as./template/default/article/special-article.html.
Aqy CMS encourages modular design, and you can createpartial/The directory stores reusable code snippets (such as sidebars, breadcrumb navigation), or createbash.htmlAs common header and footer, through{% include "partial/header.html" %}or{% extends "base.html" %}tags to reuse code, maintain the neatness and efficiency of the template.
Designing custom template considerations
- Starting from an existing template:The simplest way is to copy an existing one (for example,
article/detail.htmlThe template file, then modify it on this basis. This ensures that you have a fully functional and structurally correct starting point. - Familiarize yourself with template tags:Security CMS provides a rich set of template tags (such as
archiveDetail/categoryDetail/systemEnglish),for obtaining various data. In custom templates, you need to flexibly use these tags to display the required content. For example, using{{archive.Title}}to display the article title, or{% archiveList ... %}Call related article list. - Ensure the file exists and is named correctly:Whether it is an automatic application or manual specification, it must be ensured that the template file actually exists in the correct path, and the filename matches the set or naming rules in terms of case sensitivity.
- Testing and debugging:After modifying the template, be sure to visit the corresponding page on the frontend to test, and confirm that the display effect meets expectations.If an error occurs, you can check the background logs or error messages on the front-end page for troubleshooting.
By using the above methods, you can fully utilize the template customization capabilities of Anqi CMS, for each content module of the website