In the multi-site management system of AnQi CMS, configuring exclusive content display templates for each site is crucial for achieving brand differentiation, optimizing user experience, and meeting specific content display needs.The AnQi CMS, with its flexible architectural design, provides multiple ways to achieve this goal, whether it is from the overall site level or refined to specific content types, it can be highly customized.

Understanding the template mechanism of the AnQi CMS

Firstly, we need to understand how the Anqi CMS organizes and manages templates. All sites share a core template management area, usually located under the system root directory./templateFolder. Within this directory, you can create multiple independent template packages (also known as template themes), each of which is an independent folder containing a complete set of styles, scripts, images, and the most important.htmlTemplate file.

Each template package is defined by aconfig.jsonfile, for example, the template name (name), a unique package identifier (package), version number, description, and template type (template_type)。The template type determines whether the template is designed for responsive design, code adaptation, or independent versions for PC and mobile.AnQiCMS uses syntax similar to Django template engine, which makes the writing of template files intuitive and powerful.

The core path of the multi-site independent template configuration

Anqi CMS provides multi-level template configuration capabilities from global to local, ensuring that each site can have a unique appearance and functionality.

1. Create a new site and bind an exclusive template

This is the starting point for implementing independent site template.When you are in the AnQi CMS backend and manage 'multi-site management' to 'add a new site', the system will provide an option for you to 'select the template to be used for the new site'./templateSelect a default theme from all installed template packages under the directory.Once selected and created successfully, the site will completely use this template for content display.This means that even multiple sites running on the same server can present completely different visual styles and layouts as long as they are bound to different template packages.

2. Structure of template directory and default content type template

Each template package has its recommended directory structure, for example:

  • index/index.htmlUsed for the homepage of the site.
  • {模型table}/detail.htmlUsed for detail pages of specific content models (such as articles, products).
  • {模型table}/list.htmlUsed for list pages of specific content models.
  • page/detail.htmlUsed for detail pages of regular single pages.
  • If mobile template is enabled, there will also be onemobile/subdirectory containing mobile-specific template files.

These default template files are the basis for the specific site template package. This means that all articles within the same site will use the bound template package by default if not specified otherwise.article/detail.htmlThis layered design ensures consistency in content presentation within the site.

3. Template override for specific content types

The strength of AnQi CMS also lies in its fine-grained template coverage mechanism.After choosing the default template at the site level, you can also specify more personalized templates for specific content.The priority of this mechanism is usually: Specified template for individual content items > Specified template for categories > Default site template.

  • Specify a dedicated list template for categories:In the "Content Management" under "Document Categories" settings, each category can be configured with a "Category Template" field. If you want the article list or product list page under a certain category to have a unique layout, you can enter the corresponding template filename here (for example,download.html

  • Specify exclusive detail templates for a single document or product:In the 'Content Management' 'Add Document' or 'Edit Document' interface, there will be a 'Document Template' field. When you need a specific article or product detail page to have a unique display effect, you can directly enter the template file name here (for example,)special_product_detail.html)。This document will no longer use the default detail template of its category or site, but will instead use the exclusive template you specify.

  • Specify an exclusive template for a single page:Similarly, under 'Page Resources', the 'Page Management' provides the 'Single Page Template' field.This allows you to configure completely independent display templates for specific single pages such as 'About Us', 'Contact Information', etc., thus flexibly meeting different page requirements.

实用技巧 in template creation

The following tips can help you improve efficiency and maintainability when creating independent templates for multiple sites:

  • Use public code snippets:For elements that may repeat in multiple pages or multiple template packages, such as headers (header), footers (footer), sidebars, etc.{% include "partial/header.html" %}Introduce independent public files using tags to avoid repetition.
  • Inherit basic layout:Application{% extends 'base.html' %}and{% block content %}Tags such as these, you can design a basic layout (skeleton), and then let other templates inherit this layout, only rewriting the parts that need to be customized, thus maintaining a unified overall style and reducing redundancy.
  • Use macros to simplify repeated elements:For UI components that are highly repetitive but have different parameters, you can use:{% macro %}Tag defines reusable code blocks and calls them where needed, such as:{{ archive_detail(item) }}.
  • Mobile independent template:If your template type is "PC+Mobile" independent mode, please make sure to include each template package'smobile/Build the corresponding mobile template files under the directory, ensuring **of the browsing experience on different devices.

Through the multi-level configuration and flexible template mechanism, Anqi CMS allows you to easily implement independent template configurations for each site under multi-site management, thereby effectively supporting diverse business needs and brand strategies.


Common Questions (FAQ)

Q1: Have I created multiple sites, and will modifying a template package affect other sites?A1: It depends on whether other sites also use the same template package.If you modify a template package that is exclusive to a single site, it will only affect that site.But if multiple sites share the same template package (the same template was selected when creating a new site), then any modifications to the template package will affect all sites that use it.To avoid unnecessary mutual interference, it is recommended to create and bind an independent template package for each site that requires an independent style.

Q2: Does the Anqi CMS have a default template naming rule specified in addition to the one in the background?A2: Yes, Anqi CMS supports a set of default template file naming rules. When you do not specify a template for a specific content item in the background (such as documents, categories, single pages), the system will automatically search for template files with these default names. For example, the article detail page will try to locate{模型table}/detail.html,The article list page will search for{模型table}/list.htmlor{模型table}/list-{分类id}.html,The single page will search forpage/detail.htmlorpage/detail-{单页ID}.html. Understanding these rules will help you organize template files and apply templates without additional backend configuration.

Q3: How do I set a specific detail page template for all articles under a certain category (content model is 'article')?A3: You can enter the 'Content Management' -> 'Document Category' interface in the Anqi CMS backend to find the corresponding category for editing.In the category editing page, there is a 'Document Template' field.article_special_detail.html)。After saving, all articles under this category (unless the article itself specifies a more specific template) will be displayed using this template uniformly.If you also want the child categories to inherit this setting, you can check the 'Apply to child categories' option.