In website operation, we often encounter scenarios where we need to give unique "appearances" to specific content.This may be an 'About Us' page carrying important information, requiring a unique layout; it could also be a series of product details, hoping to show distinctive parameter comparisons; or even a content category, looking forward to presenting the list in a more attractive way.AutoCMS (AutoCMS) deeply understands the need for these fine-grained content display requirements, and therefore provides a flexible and powerful template customization mechanism, allowing us to tailor exclusive display templates for documents, categories, and single pages, etc.
The overview of Anqi CMS template mechanism
The template system of Anqi CMS is developed in Go language, adopting syntax similar to Django template engine, which makes template creation both intuitive and efficient. All template files are in.htmlFor suffix, and stored uniformly/templateThe directory. The accompanying styles, JavaScript scripts, and image static resources, will be placed in/public/static/In the catalog.
Without any special specification, the Anqi CMS will match templates based on a set of default naming rules: for example, the document detail page might default to using{模型table}/detail.html, and the category list page uses{模型table}/list.htmlEnglish, single page detail usagepage/detail.htmlEnglish, however, when these default templates cannot 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 usually consists of two steps:Create template fileandSpecify the template in the background.
1. For single-page custom template
Imagine that your website has a "Company Profile" page, which may need a layout that includes unique design elements, large text with images, or special forms, which is completely different from a regular news article or product details page.
How to operate:Firstly, you need to be in the directory of the template currently being used (for example,template/default/),create a new HTML file to carry this single-page exclusive layout. For example, if you want to create a custom template for the 'Company Profile' page, you can name itpage/company_profile.html.
Then, log in to the Anqi CMS backend and enter the 'Page Resources' under 'Page Management'.Find the single page you want to customize, click edit.On the edit page, you will find a field named 'Single Page Template' under the 'Other Parameters' section.company_profile.html。After saving, when the user accesses this "Company Profile" page, the security CMS will automatically load and use the template you specifiedpage/company_profile.htmlto display the content.
2. To customize templates for documents (articles, products, etc.)
For specific 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, hoping to have a carousel and a detailed comparison table of parameters.
How to operate:Similar to a single page, you need to be in the template directory and according to the content model (for example, the article model usually corresponds to)articleFolder, corresponding to product modelproductFolder) Create a new template file. For example, you can create aarticle/technical_report.htmlUsed to display technical reports, orproduct/photo_gallery.htmlUsed for product image sets.
Then, in the background "Content Management", find and edit the document you want to apply this custom template to.In the "Other Parameterstechnical_report.htmlorphoto_gallery.html。Save after, when the user accesses this document, the system will load the exclusive template you specified.
It is worth mentioning that the Anqi CMS also supports inDocument CategoryThe template is specified for all documents under the entire category.If you want all documents under a 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 in. This way, all documents under the category do not need to be set individually.
3. Custom 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 require large images and card layouts to highlight visual impact.
How to operate:To customize the display template for categories, you also need to create the corresponding HTML file under the template directory. The default category list template is usually{模型table}/list.htmlEnglish to customize, you can create a new template file under the corresponding model folder, for exampleproduct/list-showcase.htmlEnglish used to display the category list of selected products.
Then, in the background's 'Content Management' -> 'Document Categories', find and edit the category you want to customize the template for. In 'Other Parameters', find the 'Category Template' field, and 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. This will save you 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 meaningful filenames for your custom templates, such as:
page-about-us.html`article-download.html`