The Auto CMS provides high flexibility in content display, one very practical feature being the ability to set independent display templates for different article categories.This means you can customize unique visual styles and layouts for different categories based on their content characteristics, thereby highlighting the content, enhancing user experience, and even meeting specific SEO requirements.

To achieve this goal, we need to start from several aspects such as the preparation of the template file, the backend settings, and the design of the template content.

Understand the concepts of classification and article templates

In the Anqi CMS, templates are usually divided into two main types, each playing a different role in content display:

  1. Category template (list page template):This template is responsible for rendering the list page of articles under a certain category.For example, your website may have a "News and Information" category and a "Product Release" category. You may want the news list to be concise and clear, while the product list needs to display more product images and brief parameters.The category template is designed to meet such differentiated list display needs.
  2. Document template (detail page template):This template is used to render the detailed content page of a single article or product.For example, a technical article may require code highlighting and table of contents navigation, while a product detail page may require a slideshow, parameter table, and an online consultation button.The document template allows each content detail to be presented in the most suitable way for its characteristics.

The settings of these templates can be managed in the category management, and more detailed coverage can be applied to individual article detail pages.

Template file organization and naming conventions

Before starting the setup, make sure you have already created and uploaded the custom template file. The template files for Anqi CMS are usually stored in the root directory of the website./templateThe folder. Each set of templates should have its own independent directory, for exampledefault.

When customizing templates, AQS CMS provides some default naming conventions. If you follow these conventions, the system will automatically apply the template without any additional settings in the backend. For example:

  • Document details default custom template: {模型table}/{文档id}.html(For example}]}article/123.htmlArticle details page for ID 123)
  • The default custom template for the document list: {模型table}/list-{分类id}.html(For example}]}article/list-10.htmlArticle category list page for ID 10
  • Single page default custom template: page/{单页面id}.html

However, when we want to set an "independent" template for a specific category, the most flexible way is to explicitly specify the template file name in the category settings in the background. You can name the template file clearly and easily, for example,article/news_list_template.htmlUsed for news category list, orarticle/product_detail_template.htmlUsed for product details.

Operation steps: Set independent templates for article categories

Now, let's take a step-by-step look at how to set independent display templates for different article categories in the Anqi CMS backend.

  1. Prepare the custom template file:Before performing background settings, please make sure to create your exclusive category template and/or document template files under your theme template directory (for example), for example, you may have created:/template/您的主题名称/).

    • article/news_list.html(Used to display the list of articles under the "News Center" category)
    • article/product_showcase.html(Used to display the list of products under the "Product Showcase" category)
    • article/tech_article_detail.html(Used to display the details of articles under the "Technical Articles" category)
  2. Enter the category management interface:Log in to the AnQi CMS backend management interface. In the left menu bar, find and click "Content Management", then select "Document Category".

  3. Edit target category:In the document classification list, find the article category you want to set a separate template for (for example, "News Center"). Click the "Edit" button on the right side of the category to enter the category editing page.

  4. Set category template and document template:In the category editing page, scroll down and you will see a collapsible area named "Other Parameters".Expand this area, and you will find two input boxes for “Classification Template” and “Document Template”.

    • Category Template:Enter the custom template filename you prepare for the category article list page in this input box, for example:article/news_list.html.
    • Document template:If you want all the article detail pages under this category to use the same exclusive template, you can enter the corresponding template file name here, for examplearticle/tech_article_detail.html.

    You will also notice an option for 'Apply to subcategories'.If you check this option, all subcategories (and their articles) under the current category will inherit the category template and document template you set here, without the need to set them individually.This is very convenient for categories with hierarchical structures.

  5. Save settings:Completed after filling in, click the "OK" or "Save" button at the bottom of the page to save your changes.

  6. Preview and Test:After the settings are completed, please immediately visit your website's front-end, go to the category page of the independent template you just set (such as "News Center"), and the detail page of any article under this category, to check if the page is displayed according to the template you specified.

Template content creation utility tags

When designing your custom template, you can fully utilize the rich template tags provided by Anqi CMS to dynamically obtain and display content. For example:

  • {% categoryDetail ... %}Get detailed information of the current or specified category, such as category name, description, banner image, etc.
  • {% archiveList ... %}English: : Get the list of articles under the current category, which can be filtered by various conditions (such as recommended attributes, sorting method).
  • {% archiveDetail ... %}English: In the detail page, obtain the current article's title, content, images, custom fields, etc.
  • {% pagination ... %}English: Handle the pagination display of the article list.

The flexible application of these tags allows you to highly customize every detail of the template without directly operating the database.

Some advanced techniques and注意事项

  • Existence of template file:Make sure that the template file name you fill in the background is real and the path is correct.If the template file does not exist, accessing the corresponding page will cause an error, and the page may not open normally.
  • Background settings priority:In the AnQi CMS, the settings for the 'Category Template' and 'Document Template' fields have the highest priority. If a category meets the default naming convention (for example,article/list-10.html存在()和后台指定了自定义模板(例如article/news_list.html),则后台指定的article/news_list.html将被优先应用。
  • 模型与分类的关联:When creating a category, the content model it belongs to will be specified (such as article model, product model).Once specified, the model cannot be changed.This means that your template file should also be named and organized according to the conventions of its associated model to maintain clarity.
  • 单个文章详情页模板覆盖:If you need to set a detail page template different from the document template of the category for a specific article, you can find the "Document Template" field in the "Other Parameters" when editing the article, and fill in the exclusive template filename to override.

Through these steps and techniques, you can easily master the template customization capabilities of Anqi CMS, creating a diverse and professional display effect for your website content.


Common Questions (FAQ)

Q1: I have set up the category template, but I didn't see any changes on the category page. Why is that? A1:Please check the following points:

  1. Does the template file exist?Make sure you are in/template/您的主题名称/The template file was created in the directory and the filename is consistent with the settings in the background (including case and file extension).
  2. Is the path correct:Ensure that you enter the path relative to the theme directory in the background, for examplearticle/news_list.htmlInstead/template/您的主题名称/article/news_list.html.
  3. Cache issue:Try clearing the browser cache, or click the "Update Cache" feature in the Safe CMS backend, and then visit the page again.

Q2: How do I set up a unique detail page template for a single specific article on the website? A2:You can achieve this when editing the article.In the AnQi CMS backend, go to 'Content Management' -> 'Document Management', find the target article and click 'Edit'.article/special_event_detail.html),then save.

Q3: What are the specific differences between 'Classification Template' and 'Document Template' in terms of usage? A3:

  • Category Template:主要用于显示一个分类下的“列表”页面,例如新闻列表页、产品分类列表页。It usually cycles through multiple articles' titles, summaries, thumbnails, and includes pagination navigation.
  • Document template:主要用于显示单篇文章或产品的“详细内容”页面。It will display the full content of an article, including the main text, large images, custom fields, comments section, and links to previous and next articles.