In website operation, we often encounter scenarios where we need to give a unique "face" to specific content.It may be a "About Us" page carrying important information, needing a unique layout;It could also be a series of product details, hoping to show unique parameter comparisons;Even a content category, looking forward to presenting the list in a more attractive way.AnQiCMS (AnQiCMS) fully understands the need for refined content display and therefore provides a flexible and powerful template customization mechanism, allowing us to tailor exclusive display templates for documents, categories, and single pages.
AnQi CMS template mechanism overview
The AnQi CMS template system is developed based on Go language, adopting syntax similar to the Django template engine, which makes template creation both intuitive and efficient. All template files are in the form of.htmlwith suffix, and stored uniformly in/templateIn the directory. The accompanying styles, JavaScript scripts, and static resources such as images will be placed in/public/static/In the catalog.
In the absence of any special specification, Anqi CMS will match templates based on a set of default naming rules: for example, the document detail page may be used by default{模型table}/detail.html, for the category list page{模型table}/list.html, Single page detail usagepage/detail.htmlHowever, when these default templates fail to meet personalized needs, the function of custom independent templates becomes particularly important.
Customize an independent display template for specific content
The core of a custom template lies in 'specifying a specific template file for specific content'. This process is usually divided into two steps:Create a template fileandSpecify the template in the background.
1. Customize the template for the single page
Imagine that your website has a 'Company Profile' page, which may need a layout that includes unique design elements, large text illustrations, or special forms, which is completely different from regular news articles or product detail pages.
How to operate:First, you need to be in the directory of the template you are currently using (for example,template/default/),Create a new HTML file to host the exclusive layout of this single-page. For example, if you want to create a custom template for the "Company Profile" page, you can name itpage/company_profile.html.
Next, log in to the AnQi CMS backend, go to "Page Resources" under "Page Management".Find the single page you want to customize, click edit.In the "Other Parameters" section of the editing page, you will find a field named "Single Page Template".Enter the name of the template file you just created (only the file name and relative path), for examplecompany_profile.htmlAfter saving, when the user visits this "Company Profile" page, the Anqi CMS will automatically load and use the one you specified.page/company_profile.htmltemplate to display the content.
2. Customize templates for documents (articles, products, etc.)
For certain types of articles or products, personalized templates can also bring great value.For example, an in-depth technical analysis article may require special code highlighting areas, or a product introduction page that needs to display a large number of images, and it is hoped that there will be a carousel and a detailed parameter comparison table.
How to operate:Similar to a single page, you need to be in the template directory, according to the content model (for example, the article model usually correspondsarticleto the folder, the product model correspondsproductCreate a new template file. For example, you can create aarticle/technical_report.htmlused to display technical reports, orproduct/photo_gallery.htmlused to display product image galleries.
Then, in the background "Content Management" section, find and edit the document you want to apply this custom template to.In the "Other Parameters" section of the editing page, you will see a "Document Template" field.Enter the name of the template file you created, for exampletechnical_report.htmlorphoto_gallery.htmlAfter saving, when the user accesses this document, the system will load the dedicated template you specified.
It is worth mentioning that AnQi CMS also supports customization of templates for categories.Document CategoryThe level specifies the default template for all documents under the entire category. If you want all documents under a certain category (such as the "Software Download" category) to use a unified custom layout (such as including download buttons, version information, etc.), you can find the "Document Template" field on the edit page of that category and fill it out. This way, all documents under that category do not need to be set individually.
3. Customize templates for categories.
The category page is usually the entry point for users to browse content, and its display form often requires stronger design sense and guidance.For example, a "news center" category may need to be presented in a concise news list style, while a "success stories" category may need a large image and card layout to highlight visual impact.
How to operate:To customize the display template for categories, you also need to create the corresponding HTML file in the template directory. The default category list template is usually{模型table}/list.html. To customize, you can create a new template file in the corresponding model folder, for exampleproduct/list-showcase.html, used to display the category list of selected products.
Continue, in the background "Content Management" -> "Document Category", find and edit the category you want to customize the template for. In the "Other Parameters", find the "Category Template" field, enter the name of the template file you created, for examplelist-showcase.html.
In addition, if you want this custom category template to apply to all its subcategories, you can check the 'Apply to Subcategories' option in the same area, which can save the trouble of setting each subcategory one by one, ensuring the visual consistency of the entire category system.
Practical Tips and **Practice**
- Clear naming conventions:Choose a meaningful filename for your custom template, for example
page-about-us.html、`article-download.html