In website operation, we often hope to design unique display styles for different content types or specific pages.For example, a news article may require a concise and clear list style, while a product introduction may place more emphasis on images and detailed parameters;The "About Us" page often requires a separate design to reflect the brand image.AnQiCMS (AnQiCMS) understands the importance of these personalized needs, providing flexible template customization features that allow you to easily create a unique visual experience for different parts of the website without delving into code.
AnQi CMS is developed based on Go language, and its template engine adopts syntax similar to Django, making the creation and modification of templates very intuitive and efficient.It not only supports various modes such as adaptive, code adaptation, and independent sites for PC and mobile, but more importantly, it allows us to specify a completely different display template for specific categories, single pages, or even individual documents, thereby greatly enhancing the display and operational flexibility of website content.
How exactly should one operate to customize independent display templates for different categories or pages on a website? In fact, the whole process is very simple, mainly focusing onPrepare the template fileAndspecified application in the backgroundThese two core steps expand.
Step 1: Customize a dedicated template for website classification
Imagine that your website has news categories, product display categories, and even case sharing categories.Each category has different content features and user focus points, naturally requiring different layouts to optimize user experience.The Anqi CMS allows you to specify an independent list page template for any category.
Operation steps:
- Create or select a template file: First, you need to create a new HTML file under the current template theme directory, as the exclusive template for this category. For example, if you want to design a grid layout for a product category, you can create a file named
product/grid_list.htmlThe file(productIs the model table name belonging to the category, usually justarticleorproduct)。This file will contain all the HTML structures and data call logic that you want the category list page to display. - Apply template in the background:Log in to the AnQi CMS backend, navigate to the 'Content Management' module under 'Document Categories'.Find the category you want to customize the template, click “Edit”.In the "Other Parameters" section of the editing page, you will see a field named "Category Template".Here, simply enter the relative path and name of the template file you just created, for example
product/grid_list.htmlPlease note that the main template directory name does not need to be included, the system will automatically identify it. - Inheritance rules:If you wish to apply this custom template to all subcategories under the current category, you can find the option 'Apply to subcategories' below the 'Category template' field and check it.Otherwise, the subcategory will continue to follow the parent category or the default template of the model.
- Default naming convention:It is interesting that AnQi CMS also provides a convenient default naming convention. If you name the template file as
{模型table}/list-{分类ID}.htmlfor examplearticle/list-10.htmlThen this template will be automatically recognized and applied to the article category with ID 10, saving the extra backend configuration steps.
In this way, you can display your product categories with exquisite grid images, while the news category maintains the traditional title list, with each section exuding professionalism.
Chapter 2, specify an independent template for a single document
Not all articles or product detail pages are suitable for a unified template.Certain special documents, such as software download pages, important thematic reports, or detailed product specification comparison pages may require a more unique layout.
Operation steps:
- Prepare an independent template: Likewise, you need to prepare a separate template file for this special document. For example, a software download page can create a
archive/download_page.htmlthe file (archiveis usually the default model table name for the article model) - Specify in the background:In AnQi CMS backend, go to 'Content Management' -> 'Publish Document' or 'Edit Document'.In the "Other Parameters" area of the document editing page, find the "Document Template" field.Enter the name of your custom template file, for example
archive/download_page.html. - Model table naming convention:Similar to categories, documents also support default naming conventions. If you name the template file as
{模型table}/{文档ID}.htmlfor examplearticle/123.html), then the article with ID 123 will automatically apply this template without the need for manual settings.
This feature allows operation personnel to target the optimization of the display effect of each key content, whether for higher conversion rates or better reading experience.
Three, to customize the display template for a specific single-page
For pages like "About Us", "Contact Information", and "Terms of Service" that are independent and usually contain little content, a unique layout can better convey brand information or guide users to complete specific actions.
Operation steps:
- Create a single page template:Create an HTML file for this single page under your theme directory. For example, create one for the "About Us" page.
page/about_us.html. - Back-end association: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 'Single Page Template' field on the editing page, enter the name of the template file you created, for example
page/about_us.html. - Default naming convention:The single page also supports the default naming rule, you can name the template.
page/{单页ID}.htmlfor examplepage/5.html),the system will automatically apply this template to the single page with ID 5.
This high degree of customization makes your website stand out from the crowd, every corner exuding a unique charm.
Tips for storing and naming template files:
When customizing templates, the storage location and naming method of the template files are crucial. All template files should be placed in/templatethe directory of the theme you are using (for example/template/default/Fill in the template name in the background, just the path and filename relative to the theme directory, for examplearticle/detail.htmlorpage/my_custom_page.html.
Good file organization habits can make your template management clearer, for example, placing article-related templates inarticle/folders, and product-related ones inproduct/Under the folder. Moreover, by using the powerful template tag function of Anqi CMS, you can flexibly call various data of the website in custom templates to achieve rich and diverse content display.
With these features, AnQi CMS not only provides an efficient content management backend, but also gives you complete control over the website front-end presentation, making your website stand out among its peers.
Frequently Asked Questions (FAQ)
Q1: The custom template file should be placed in which directory of AnQi CMS?A1: You need to place the custom template file in the root directory of AnQi CMS./templateInside the folder, then enter the directory of the current theme template you are using (for example/template/default/). Under the theme directory, you can create subdirectories based on file type (for examplearticle//product//page/),put the corresponding custom template file in it.
Q2: If I set a custom category template, will the document detail page under this category automatically use this template?A2: No. Custom 'category template' only affects the list page display of the category.The document detail page has an independent "document template" setting. If you want all document detail pages under a certain category to use the same custom template, you need to find the "document template" field in the edit page of that category, or specify it separately in the edit page of each document.
Q3: Do you need to include.htmlthe suffix?A3: Yes, when filling in the template name in the background, you need to include the complete.htmla suffix, for examplearticle/my_special_list.htmlMake sure the path is relative to the current theme template directory.