AnQiCMS as a system aimed at providing an efficient content management solution for small and medium-sized enterprises and content operation teams, its template file organization structure under the multi-site mode is carefully designed to ensure flexibility, maintainability, and independence.In a multi-site environment, AnQiCMS allows administrators to manage multiple sets of templates in a unified template library and select an appropriate template set for each site, thereby achieving decoupling of content and presentation.
All template files are stored in the AnQiCMS installation directory./templateIn the root directory. Each independent template set is organized in a separate subdirectory under this root directory, for example/template/defaultor/template/my_custom_theme. Each template subdirectory contains aconfig.jsonFile, this file defines the template name, version, author, description, and applicable types (such as adaptive, code adaptation, PC+mobile independent site mode, etc.). This is the key for AnQiCMS to identify and manage templates. Static resources related to the template, including stylesheets (CSS), JavaScript scripts, and images, are stored uniformly./public/static/The directory. Usually, these static resources are further organized into subdirectories by template name, for example/public/static/default/css/style.cssEnsures clear separation of template resources from code.
AnQiCMS's template file organization mode is mainly divided into two types, to adapt to different development preferences and project requirements.
The first one isFolder organization mode. In this mode, template files reflect their functionality and page type through directory levels. For example, common page elements such as headers and footers are typically abstracted tobash.html文件中,而代码片段(如侧边栏或面包屑)则存放在partial/子目录。特定的页面类型也有其对应的目录结构,比如首页是index/index.html,文档模型的首页是{模型table}/index.htmlEnglish document details page is{模型table}/detail.html. For specific document ID or category ID, AnQiCMS also supports more detailed template file naming, such as{模型table}/detail-{文档ID}.htmlor{模型table}/list-{文档分类ID}.html. Other than that, there is the comment list (comment/list.html)、Online留言 (guestbook/index.html)、Single Page Details (page/detail.html) and search page (search/index.html)、Tab Page (tag/index.htmlortag/list.html) and various error pages (such aserrors/404.html,errors/500.html) also have clear storage paths.
The second one isFlat file organization mode。With a different folder organization mode, this mode tends to place all template files directly in the template root directory, distinguishing page types by the prefix of the file name. For example, the home page isindex.html,model home page is{模型table}_index.html,document detail page is{模型table}_detail.htmlThis approach reduces the directory hierarchy, making file management more direct, but may require stricter file naming conventions to avoid confusion. Similarly, public codebash.htmlAnd the code snippet directorypartial/Still exists. Error page aserrors_404.htmlanderrors_500.htmlAlso uses flattened naming.
No matter which organization mode is adopted, AnQiCMS provides independent mobile template support. The mobile templates are stored in the main template directory undermobile/In the subdirectory, the internal directory structure or file naming method is consistent with the desktop template, effectively implementing separate management of the PC and mobile interfaces.
AnQiCMS also further enhances the template customization capabilities through flexible custom naming conventions. In addition to the default structure mentioned above, the system allows developers to create template files with independent names for specific documents, lists, or single pages, for example, creating a template file with an independent name for the document with ID 10.{模型table}/{文档id}.htmlor create a category with ID 1{模型table}/list-{分类id}.htmlThis means that even within a shared template set, you can specify unique visual and functional presentations for very specific pages without needing any additional configuration on the backend.
On the whole, the template file structure of AnQiCMS under the multi-site mode reflects a balance between centralized management and flexible customization. Through unified/templateLibrary, each site can easily select and apply the required template sets, and the clear directory structure and naming conventions within the template sets greatly simplify the development, maintenance, and expansion of templates.
Frequently Asked Questions
1. Do you need a set of independent template files for each site in the multi-site mode of AnQiCMS?
AnQiCMS's multi-site mode does not require each site to have a separate set of template files. Instead, all template sets are stored in the AnQiCMS installation directory under/templateIn the root directory.Each subdirectory represents a complete template set.When you create a new site in the AnQiCMS backend, you can select one from these existing template sets as the default template for the new site.This mechanism implements the sharing and reuse of template resources, reducing storage space usage and management complexity.
2. How to customize a template for a specific site under AnQiCMS multi-site mode?
To customize templates for specific sites under the multi-site mode, you have two main methods.Firstly, you can directly modify the files in the selected template set, but this will affect all sites using that template set./templateCreate a new template subdirectory under the directory/template/custom_for_siteA),Copy the existing template to modify it, or start from scratch. Complete the creation and configuration of the new template set (includingconfig.jsonAfter uploading the file), log in to the backend of the site you want to customize, and then apply this new template set through the template management feature.
3. How to manage and reference static resources (CSS, JS, images, etc.) in the template file under the multi-site mode?
Static resources in the template file are usually stored in/public/static/The directory, and organize according to the template package name, for example/public/static/default/css/style.css. When referencing these resources in the template file, you can use the AnQiCMS provided{% system with name="TemplateUrl" %}Label to dynamically retrieve the static resource root path of the current site template. For example, the style sheet can be referenced as<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">. So, no matter which template the site switches to, the system can automatically point to the correct static resource path, ensuring that the resources are loaded correctly.