How to set independent display templates for different article categories in AnQi CMS?

Calendar 👁️ 63

AnQi CMS provides extremely high flexibility in content display, one very practical feature is to set independent display templates for different article categories.This means you can customize unique visual styles and layouts for different categories of content, thus better highlighting the content, improving user experience, and even satisfying specific SEO needs.

In order to achieve this goal, we need to start from several aspects such as preparing the template file, setting up the background, and designing the template content.

Understand the concept of category and article templates

In 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 the needs of this differentiated list display.
  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 carousel, parameter table, and 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 made in the category management, and can be covered more finely for individual article detail pages.

Template file organization and naming conventions

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

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

  • Document detail default custom template: {模型table}/{文档id}.html(For example)article/123.htmlPage for article with ID 123)
  • Document list default custom template: {模型table}/list-{分类id}.html(For example)article/list-10.htmlPage for article category list with ID 10)
  • Default custom template for single page: 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. You can name the template file in a clear and understandable way, for example,article/news_list_template.htmlUsed for news category list, orarticle/product_detail_template.htmlUsed for product details.

Operation steps: Set an independent template for article classification

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

  1. Prepare to customize the template file:Before performing background settings, please make sure to create your exclusive category template and/or document template files in your theme template directory (for example/template/您的主题名称/), such as the following:

    • article/news_list.html(Used to display the list of articles in the "News Center" category)
    • article/product_showcase.html(Used to display the list of products in 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 category list, find the article category you want to set up a separate template for (such as "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 the 'Category Template' and 'Document Template' input boxes.

    • Category template:Enter the custom template filename you prepared for the category article list page, for example:article/news_list.html.
    • Document template:If you want all the article detail pages under this category to use the same dedicated 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 classification with hierarchical structure.

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

  6. Preview and Test:After completing the settings, please immediately visit the front end of your website, go to the category page of the independent template you just set up (for example, "News Center"), and check the details page of any article under this category to see if the page has been displayed according to the template you specified.

Practical tags for template content creation

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

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

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

Some advanced tips and注意事项

  • Existence of template file:Make sure the template filename you fill in the background actually exists 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.
  • Back-end settings priority:In AnQi CMS, the settings of the 'Category Template' and 'Document Template' fields in the background have the highest priority. If a category conforms to the default naming convention (for example,article/list-10.htmlExists) and the background has specified a custom template (such asarticle/news_list.html), then the specified one by the backgroundarticle/news_list.htmlwill be applied first.
  • Model and category association:When creating a category, the content model it belongs to will be specified (for example, 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 the model it belongs to, to maintain logical clarity.
  • Single article detail page template override:If you need to set a different detail page template for a specific article that is different from the document template of the category it belongs to, you can find the 'Document Template' field in the 'Other Parameters' when editing the article and fill in the name of the exclusive template file to overwrite it.

By following these steps and techniques, you can easily master the template customization capabilities of AnQi CMS, creating diverse and professional display effects for your website content.


Frequently Asked Questions (FAQ)

Q1: I have set up the category template, but I did not see any changes when accessing the category page, why is that? A1:Please check the following points:

  1. Does the template file exist:Make sure you are/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 you fill in the relative path to the topic directory in the background, for examplearticle/news_list.htmlinstead of/template/您的主题名称/article/news_list.html.
  3. Cache problem:Try clearing the browser cache or click the "Update Cache" feature in the Anqi CMS backend, then visit the page again.

Q2: How do I set a unique detail page template for a single specific article on a website? A2:You can implement it while editing the article. In AnQi CMS backend, go to 'Content Management' -> 'Document Management', find the target article and click 'Edit'.In the 'Other Parameters' area of the article editing page, find the 'Document Template' input box, and enter the custom template file name you designed for this article (such asarticle/special_event_detail.html),then save it.

Q3: What is the specific difference between 'Category Template' and 'Document Template' in terms of usage? A3:

  • Category template:It is mainly used to display a "list" page under a category, such as a news list page, product category list page.It usually cycles through multiple articles' titles, summaries, thumbnails, and includes pagination navigation.
  • Document template:It is mainly used to display the detailed content page of a single article or product.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.

Related articles

How to implement the 'Recommended Attributes' tag highlighting in the front-end of AnQi CMS?

AnQi CMS provides a powerful content management function, among which the "recommended attribute" tag is a very practical tool in content operation.It can help us effectively organize and highlight the important content on the website, whether it is to improve the user experience or to better optimize SEO, these properties can play a key role.Understanding "Recommended Attributes": A Tool for Content Operations In Anqi CMS, "Recommended Attributes" are special identifiers set for each document (such as articles, products, etc.).

2025-11-08

How to display the contact information and social media links on AnQi CMS templates?

In website operation, clearly and effectively displaying contact information and social media links is crucial for building customer trust and promoting interaction.AnQiCMS (AnQiCMS) provides a convenient and flexible way to easily integrate key information into website templates. --- ### One: Prepare: Configure contact information and social media in the Anqi CMS backend Before displaying contact information and social media on the website front end, we need to configure it in the Anqi CMS backend.This is like preparing a complete business card for our website.1

2025-11-08

Does AnQi CMS support automatic conversion of images to WebP format to optimize display speed?

During the process of building and operating a website, the speed of image loading is always one of the key factors affecting user experience and search engine optimization.The size of an image directly affects the loading efficiency of a page.Many website operators are looking for more efficient image formats to improve website performance.So, for the Anqi CMS we are using, does it support automatic conversion of images to WebP format to optimize the display speed of the website?The answer is affirmative. Anqi CMS fully considers the needs of website performance optimization, and built-in support for WebP image format.This practical feature

2025-11-08

How does AnQi CMS display related article lists based on keywords or relevance?

In content management and website operation, how to effectively improve user experience, extend visitors' stay on the site, and optimize search engine crawling efficiency is the focus of every operator.Among them, presenting highly relevant recommended content to the current article is undoubtedly an effective method.AnQiCMS as an efficient content management system fully considers this requirement and provides flexible and powerful functions to easily achieve this goal.### Core Function Analysis: The Usefulness of `archiveList` Tag AnQiCMS

2025-11-08

How to configure and display the Banner slideshow image on the Anqi CMS homepage?

In Anqi CMS, configuring and displaying the Banner carousel image on the homepage is a key step to enhance the visual appeal and content presentation of the website.This process involves uploading and grouping of background images, as well as writing front-end template code. ### One, configure Banner Carousel Image in Background The Banner images on the homepage are not randomly stacked, they need to be carefully managed to ensure they are displayed as expected on the front end.AnQi CMS provides a flexible way to handle these images: 1. **Image upload and grouping:** Typically

2025-11-08

How to obtain and display custom parameter fields on the Anqi CMS article detail page?

In website operation, we often need to display personalized information beyond standard titles, content, and publication dates.AnQi CMS, with its highly flexible content model, gives us the ability to add custom parameter fields to articles, products, and other content, thereby meeting various diverse display needs.This article will thoroughly explain how to obtain and elegantly present these custom parameter fields on the article detail page of Anqi CMS, making your content more expressive.

2025-11-08

How to display the directory or title structure of article content in AnQi CMS?

On a content-rich website, providing a clear table of contents or title structure for long articles can greatly enhance the user's reading experience and also help search engines better understand the hierarchy of page content, thereby having a positive impact on SEO performance.AnQi CMS is well-versed in this and provides flexible and powerful features to easily meet this requirement.

2025-11-08

How to use the Tag feature of AnQi CMS to display related content aggregation pages on the front end?

The AnQi CMS provides a powerful and flexible tag (Tag) feature that helps us better organize content, improve the website's SEO performance, and provide users with a more convenient way to discover content.By making good use of tags, we can easily create content aggregation pages, allowing visitors to quickly find related articles or products based on their interests.Understanding the Core Value of Tag FunctionWhen we assign one or more tags to a document

2025-11-08