In website operation, we often encounter such needs: a specific product display page needs a unique layout to emphasize its features, or an important event special page needs special design to attract users, or a single page like "About Us" wants to show a different brand character.AnQi CMS provides us with a flexible way to customize exclusive display templates for these unique content needs, thereby greatly enhancing the visual appeal and user experience of the website.
The Anqi CMS template system has adopted the syntax of the Django template engine, with its intuitive and efficient features, providing great convenience for content creators and developers.It supports us in specifying different template files based on content ID (such as a specific article, product) or category ID (such as a category of articles, product column) to ensure that every corner of the website can accurately convey information.
Scenarios and value of custom templates
Why do we need to customize templates for specific content? This is usually due to the following considerations:
- Emphasize the core contentFor key products, time-limited activities and other important content, customizing exclusive templates can break the conventional layout and more effectively guide users' attention, promoting conversion.
- optimize user experience: Provide the most suitable reading and interaction templates for different types of content, such as using large image layouts for content mainly with images, and focusing on clear layout and code highlighting for technical documents.
- Strengthen brand image:On some core pages, such as "About Us", "Contact Us", and other single pages, customized templates can better integrate brand elements and deepen users' impression of the brand.
- Adapt marketing strategy: Coordinate with specific marketing activities, quickly switch or launch special page templates with marketing elements to improve operational efficiency.
AnQi CMS through a set of concise template file naming conventions makes this process easy.
Custom document (article/product) detail page template
If you wish to apply a unique layout to a specific article or product detail page, you can specify it by editing the document in the background under the "Other Parameters" field in the "Document Template" field.
Before specifying the template, you need to create this special template file. Anqi CMS stipulates that the custom template files for document details should be placed in/templateThe corresponding model folder under the catalog. For example, for the article model, it is usuallyarchivefolder; for the product model, it isproductfolder. The file naming format is{模型table}/{文档ID}.html.
For example, if the ID of an article document you have is123and the model table name isarchive, you can create a template file namedarchive/detail-123.html. Alternatively, if you have a product ID of456The product namedproductYou can createproduct/detail-456.html.
In these customized template files, you can still use as in the general template, you can usearchiveDetailTags or go through directly{{archive.Title}}In order to call various detailed information and custom fields of the current document to build the unique display effect you expect.
Customized category (column) list page template
For a specific category (such as the list page under the "News Dynamics" column, or the product list under the "Latest Products" category), you may wish to have a different list display style than other categories.AnQi CMS allows you to customize a dedicated list template for each category.
Similarly, you need to/templateCreate a template file in the corresponding model folder under the directory. The naming format of the category list page is{模型table}/list-{分类ID}.html.
For example, if there is an article category ID is10, the model table name isarchiveYou can createarchive/list-10.htmlFile. If there is a product category ID of20, the model table name isproduct, then it can be createdproduct/list-20.html.
After creating the template file, log in to the Anqi CMS backend, go to the "Content Management" under the "Document Category" page, and edit the corresponding category. In the "Other Parameters", find the "Category Template" field, and fill in the name of the template file you created (for examplelist-10.htmlIt is worth mentioning that there is also an option to apply to subcategories. If you check it, all subcategories under this category will automatically inherit this custom template, saving the trouble of repeating the setting for each subcategory.
In these custom category list templates, you can usecategoryDetailtags to obtain the detailed information of the category itself and combinearchiveListLabels to display the document list under the category, achieving various complex layouts and functions.
Custom single page template
The single-page feature of Anqi CMS is very suitable for creating independent pages such as "About Us", "Contact Us", "Terms of Service", etc.If you want a single page to have a completely independent visual design, you can also customize a dedicated template for it.
The template files for single-page layouts are usually located in/template/page/the directory. The file naming format can bepage/{单页面ID}.htmlor more flexibly, usepage/{自定义URL别名}.htmlFor example, if you have a single page with an ID of1Can createpage/1.htmlIf your "About Us" page is set up with a custom URL alias in the backendabout_usThen you can createpage/about_us.html.
When editing a single page in the background, enter the name of the template file you created in the "Single Page Template" field (such asabout_us.html),The system will load the template you specified when accessing this page. Within the template, you can usepageDetailtags to obtain the title, content, images, and all other information of a single page.
The storage of template files and basic structure
All customized template files should be stored in the root directory of the website/templateIn the folder. If you have enabled the mobile adaptation mode and need to customize the template for mobile, you should place the mobile template file inmobileThe internal structure is consistent with the PC template in the subdirectory.
All template files should use.htmlAs a suffix, and use UTF-8 encoding uniformly to avoid garbled characters issues. The Anqi CMS template system is based on Django style, which means you can use variables flexibly in templates ({{变量}}), conditional judgments ({% if ... %}), loop ({% for ... %}) and various built-in tags and filters to build rich pages.
Practical skills for customizing templates.
When customizing templates, in addition to the above method of creating exclusive template files, there are some practical skills that can help you work more efficiently:
- Flexibly apply conditional judgment: For some pages that only require minor adjustments, it is not necessary to create a completely new template file. You can use the general
detail.htmlorlist.htmltemplate, by using `{% if