AnQiCMS provides excellent flexibility in website content management, especially in handling the display of category pages. It is not limited to a fixed layout, but allows users to set personalized display templates for category pages based on different business needs and design concepts.This is an extremely practical feature for operators who hope to enhance user experience, strengthen brand image, or optimize specific SEO strategies through differentiated content display.
How is it implemented to customize the display template of the category page in AnQiCMS?This is mainly due to the flexible template mechanism of the system, which provides two main ways to meet your customization needs.
AnQiCMS template mechanism overview
AnQiCMS's template system is based on a syntax similar to the Django template engine, using.htmlAs a template file suffix, and place all template files in/templateUnder the directory. You can create your own template theme folder here, and organize your template files within it.This design makes template creation very intuitive and easy to manage.
When customizing the category page template, AnQiCMS provides two paths: one is to use the system's predefined naming convention for automatic matching, and the other is to manually specify the template for a specific category through the backend settings.
Method one: using AnQiCMS's convention-based naming for automatic matching
AnQiCMS provides an intelligent template matching mechanism.When you do not explicitly specify a template for a category, the system will automatically search for and load the corresponding template file according to a set of preset rules.This is particularly suitable for scenarios with a large number of categories, and the display structure of these categories is mostly similar.
The most common category list page template, AnQiCMS will try to find the following two files in your template theme folder:
- General model list templateFor example, if you have an 'article' content model, the system will look for a file named
{模型table}/list.htmlsuch asarticle/list.htmlorproduct/list.html)。If this file exists and no more specific template is specified, all list pages of categories belonging to the model will use it. - Specific category ID template: If you want to design a unique layout for a specific category (such as a category with ID 12) without manually setting it in the background, you can create a named
{模型table}/list-{分类id}.htmlsuch asarticle/list-12.htmlWhen the user visits the article category list page with ID 12, the system will load this more specific template first.
This naming convention allows you to achieve unified or localized design adjustments at a lower maintenance cost when managing a large number of categories.
Method two: flexibly specify the template through the background settings.
If some of your categories require a completely unique display style, even if the default conventions cannot meet the needs, AnQiCMS also provides the powerful function of directly specifying templates in the background.This provides great convenience for operators who need highly customized pages (such as specific product display pages, special topic activity pages, or corporate solution pages).
To specify a category template from the backend, you can follow these steps:
Create a custom template fileFirstly, in your AnQiCMS theme folder (for example,
/template/您的主题名/Create a new HTML template file inside, you can place it in any subdirectory, such ascustom/special_category.htmlMake sure the content of the template file meets your design requirements.Log in to the backend and edit categories: Next, log in to the AnQiCMS backend management interface, navigate to the 'Content Management' menu on the left, and click the 'Document Categories' option.
Specify category templateIn the document category list, find the category you want to customize the template for, and click the "Edit" button on the right.After entering the category editing page, scroll down to find the "Other parameters" section.Here, you will see a text box named "Category Template".
Enter template pathEnter the path and filename of the custom template file you just created relative to the root directory of your theme. For example, if you create a file is
custom/special_category.htmlThen fill incustom/special_category.html.Apply to subcategory (optional)In the input box below the "Category Template", you will also see an option for "Apply to Subcategories".By default, the category template does not automatically inherit to the subcategories.If you want all subcategories under the current category to use this custom template you have set, you can check this option.
After completing and saving the above settings, when the user visits this specific category page, AnQiCMS will load the custom template specified in the backend to display the content.
Please ensure that the template file path you have entered is accurate, as if the system cannot find the corresponding template file, it may cause the category page to fail to open normally.
Useful hints for custom category template customization
In your custom category template, you can fully utilize various template tags provided by AnQiCMS to obtain and display data. For example:
- Use
{% categoryDetail ... %}Tag to get detailed information about the current category, such as category name, description, Banner image, etc. - Use
{% archiveList ... %}Tag to get the document list under the category, and it can be sorted, filtered, and paginated according to requirements. - Don't forget to optimize the page SEO, through.
{% tdk ... %}Tag to ensure the correct setting of page title, keywords, and description. - If your website supports mobile, don't forget to
mobile/Create the corresponding mobile template under the directory to provide a cross-device browsing experience. - During template development, it is a good habit to preview frequently, which can help you discover and correct problems in time, ensuring that the final effect meets expectations.
By combining conventional naming and flexible back-end specifications, AnQiCMS makes template customization for category pages both efficient and powerful.You can choose the most suitable strategy according to your specific needs to create a website page that is both beautiful and practical.
Frequently Asked Questions (FAQ)
1. If the custom category template file I specify does not exist, how will the category page display?
If AnQiCMS cannot find the custom category template file you set at the specified path, the category page will not load normally and display an error message.To avoid this situation, please confirm that the corresponding template file has been uploaded to the correct path after specifying the template name in the background.
2. How to obtain the name and description information of the current category in a custom category template?
In a custom category template, you can use{% categoryDetail with name="Title" %}to obtain the category name,{% categoryDetail with name="Description" %}Get the category description and othercategoryDetailSupported fields to get detailed information about the current category. These tags will automatically identify the category of the current page, no need to specify an ID manually.
3. Can I set different display templates for the PC and mobile end of the same category?
Of course you can. AnQiCMS supports multi-terminal templates. You just need to create a folder namedmobile/in your template theme folder. Then, in `mobile/