The website content management of AnQi CMS provides great flexibility, among which customizing the display style of category pages is a very practical feature.By setting custom templates for different categories, you can easily let news, products, cases, and other types of category pages present unique designs and content layouts, thus better satisfying user browsing needs and brand display strategies.

Why do you need a custom classification template?

By default, the Safe CMS will use a set of generic list templates for all categories (usually{模型table}/list.htmlThis may lead to a monotonous visual effect across all category pages.However, different categories often carry different content attributes and marketing goals.For example, a 'Company News' category may require a concise list of titles and publication dates, while a 'Product Showcase' category may need large images, prices, and more detailed product parameter filtering functions.

  • Enhance user experience:Provide the most suitable layout and information display method based on content type, allowing users to find the information they need faster.
  • Strengthen brand image:Design a unique style for specific categories to better convey brand characteristics and professionalism.
  • Optimize content marketing:)Highlight key information, guide user behavior, and improve conversion rates.
  • Achieve personalized display:Even different categories under the same content model can have completely different visual presentations.

AutoCMS is exactly what makes such customization possible with its flexible content model and easily expandable template mechanism.

The core mechanism of AutoCMS custom category template

AutoCMS provides two main methods to implement custom templates for category pages:

  1. Follow the default naming conventions:The CMS supports some default template file naming rules.If the template file you create meets these rules, the system will automatically recognize and apply them without any additional settings in the background.

    • For a specific category, you can create a template named{模型table}/list-{分类ID}.htmlThe template file. For example, if you have an article model category ID of 10, you can createarticle/list-10.html.
    • For all categories under a certain content model (unless overridden by a more specific category template), you can create a template file named{模型table}/list.htmlas the default template for the category page of the model.
  2. Through the backend interface, specify the template:This is the most commonly used and most flexible way.You can specify which custom template file to use for this category on the category editing page in the background.This method has a higher priority than the default naming convention, that is, if you specify a custom template for a category, even if there is a template file that conforms to the naming convention, the system will use the template you manually specified first.

Next, we will focus on explaining the specific steps for specifying custom templates in the backend.

Specific operation steps

To set custom templates for the categories in AnQi CMS, to change the page display style, mainly follow the following steps:

Step one: Prepare the custom template file

Firstly, you need to create or modify a template file in the current template theme folder.

  1. Find the template directory:Log in to your server file system, navigate to the installation directory of the AnQi CMS/template/Folder. In this folder, you will see the name of the template theme you are currently using (for exampledefault). Enter the template theme folder.
  2. Create a template file:In your template theme folder, you can create a new one under the corresponding subfolder (such asarticle/productetc.).htmlFile, or directly create in the root directory. For example, if you want to customize a template for article categories, you can createarticle/custom-article-list.html. Give the template file a meaningful name for easy identification in the future.
  3. Write template content:
    • Suggest starting from an existing template:The simplest way is to copy the existing category list template from the current template theme (for example,article/list.htmlorproduct/list.html),then paste its content into the newly createdcustom-article-list.htmlthe file.
    • Use the SafeCMS tag:In the template file, you can use various tags provided by the AnQi CMS according to your needs, for example:
      • {% archiveList %}Used to get the document list under the category. You can set different parameters to control the display quantity, sorting method, etc.
      • {% categoryDetail %}:用于获取当前分类的详细信息,如分类标题、描述、Logo图等。
      • {% system %}:获取网站全局设置信息。
      • {% pagination %}:用于生成分页链接。
      • and various conditional judgments({% if %}), loop traversal ({% for %})etc., Django template engine syntax.
    • Design layout and style:In this file, you can freely adjust the HTML structure, introduce CSS styles (usually stored in/public/static/the directory), to achieve the page layout and visual effects you want.

Step two: Enter the classification management interface

Log in to the AnQi CMS backend management system, find and click on the left navigation bar“Content Management”then selectDocument Classification.

Step three: Select and edit the target category

In the document classification list, find the category you want to apply a custom template to, and click the button on the right.“Edit”Click the button, enter the category editing page.

Step four: specify the category template

In the category editing page form, scroll down, findOther Parametersthe part, expand it. You will see a name'Category Template'field.

  1. Enter the template file name:In the input box of the "Classification Template" field, enter the relative path and file name of the custom template file you created in Step 1. Be sure to fill it in correctly, for example,Step 1in.article/custom-article-list.html.Note:Do not include the template theme folder name when filling in, just need the relative path starting from the content model folder (if your template file is placed directly inarticleFolder under) or directly write the filename (if the template file is placed in the root directory of the template theme).
  2. Consider inheritance of subcategories:Under the "Classification Template" field, you will also see one named“Is applied to subcategory”.
    • If you want all subcategories (including multi-level subcategories) under this category to follow your current custom template setting, please check this option.
    • If you want the subcategory to maintain its default template or have an independent custom template, do not check this option.

Step five: Save and verify

  1. Save category information:Click the bottom of the page.“OK”Button, save your changes to the category settings.
  2. Clear cache:Return to the main background page, click the left navigation bar'sUpdate CacheButton, clear system cache, ensuring that template changes take effect immediately.
  3. Visit the front desk for verification:Open the browser, visit the category page you just modified (by clicking the "View" link in the category list or directly entering the category URL), and check if the new custom template has been successfully applied and if the page style and layout meet your expectations.

By following these steps, you can set exclusive custom templates for categories in the Anqi CMS, achieving highly personalized website page displays.


Common Questions (FAQ)

1. My custom template file should be placed in which directory?Your custom template file should be placed in the directory where the AnQi CMS is installed./template/您的模板主题名称/Folder. For example, if the template theme you are using isdefault, and this template is used for the category list of the article model, you can place it in/template/default/article/the directory, the filename ismy-custom-category.html.

2. Why did I set up a category template but there was no change on the front-end page?This usually has several reasons:

  • Cache not cleared:After modifying the template or background settings, please make sure to go to the background and click 'Update Cache'.
  • Template file name or path error:Please check carefully.