As an experienced CMS website operation personnel of an enterprise, I know that a flexible and efficient template system is crucial for the presentation of website content and user experience.The AnQi CMS was designed with full consideration of the customizability and ease of use of the templates, allowing both beginners and experienced developers to easily master it.Next, I will elaborate on how to define a new template in Anqi CMS and analyze it in depthconfig.jsonThe file plays a core role in this process.
To define a new template for AnQi CMS, first you need to be in the root directory of the system./templateCreate a new subdirectory in the folder. The name of this subdirectory will represent your new template, for example, you can name itmy_new_themeorcorporate_design. This new folder is the base location where all files of your new template are stored.
There is a crucial file in the root directory of the new template, that isconfig.json. This file is the 'ID card' and 'instruction manual' of the template, it informs the Anqi CMS system of the basic information, type, and status of the template. It can be said that there is noconfig.jsonFile, your new template cannot be recognized and loaded correctly by the system.
Let's learn more in detail.config.jsonThe role of each field in the file:
in the filenameThe field is used to specify the display name of the template, which is usually the name seen by the user in the back-end management interface, such as 'Default Template' or 'Corporate Official Website Style'.packageThe field is the unique identifier for the template, corresponding to the one you create in/templatethe directory, and it only supports letters and numbers.versionThe field allows you to customize the version number of the template, which is convenient for you to manage the iterative updates of the template.descriptionThe field provides a brief description of the template features, allowing other users or future you to quickly understand the characteristics of the template.
To clarify the ownership and origin of the template,authorThe field is used to fill in the author information of the template, whilehomepagethe field can provide the author's website link.createdThe field records the creation time of the template, in accordance with2022-05-10 22:29:00such a specific format.
template_typeIsconfig.jsonA very critical setting that determines the template adaptation mode. Anqi CMS supports various adaptation modes including0representing the adaptive mode (templates automatically adjust the layout on different devices),1Represents the code adaptation mode (requires writing different HTML structures for PC and mobile), as well as2The computer + mobile independent site mode (PC and mobile end have completely independent template files, and usually also cooperate with independent mobile domain).Choose the appropriate template type to ensure your website provides a good browsing experience across different devices.
Finally,statusfield indicates the enabled state of the template. The optional values are0(disabled) or1(In use). It should be noted that only one template can be used in all installed templatesstatusThe value is set to1, which means that only one template can be enabled at a time in Anqie CMS.
Onceconfig.jsonThe file configuration is complete, next is to build the specific file structure of the template.AnQi CMS provides two main template organization modes: 'Folder Organization Mode' and 'Flattened File Organization Mode'.
Under the "folder organization mode", template files are categorized into different subfolders according to their functions and content types, for exampleindex/index.htmlUsed for the homepage,{模型table}/detail.htmlUsed for document detail pages,partial/The catalog stores reusable code snippets such as headers, footers, and sidebars. This structure helps maintain the clarity and modularization of template files.
Compared to this, the "flattened file organization pattern" places all the main template files directly under the root directory of the template, for exampleindex.htmlrepresents the home page,{模型table}_detail.htmlRepresents the document detail page. This pattern may be more suitable for small or simple website templates.
No matter which organizational pattern you choose, if yourtemplate_typeSet to code adaptation or PC + mobile independent site mode, you need to create one in the template root directorymobile/The subdirectory, and copy the mobile template files similar to the PC template structure within it. In this way, the AnQi CMS can automatically load the corresponding template according to the user's access device.
The AnQi CMS also supports more fine-grained template specification for specific content items (such as document details, category pages, or single pages). This means you can create a template for the "About Us" page.page/about.htmlThis is a dedicated template, and it is associated with the corresponding single page in the background management interface. This greatly enhances the flexibility of the template and the personalized display of content.
In short,config.jsonThe file is the starting point for defining a new template, providing all necessary information for the security CMS to identify, classify, and manage templates. Proper configuration throughconfig.jsonFollow the template organization conventions, and you will be able to fully utilize the powerful functions of Anqicms, creating highly customized and user-friendly websites.
Frequently Asked Questions
Q1: If myconfig.jsonIf the file is missing or the configuration is incorrect, how will the system handle it?Ifconfig.jsonIf the file is missing or one of the key fields (such aspackageornameIncorrect configuration, the Anqi CMS system will not be able to correctly identify and load your template, which may cause the website to display incorrectly, or the template may not be found in the background template management list.The system usually reverts to the default template or displays an error message.Therefore, ensureconfig.jsonFor the template to run normally, it is a prerequisite that the file is always present and the configuration is correct.
Q2: Can I use different template engines or syntax for PC and mobile within the same template folder?No.config.jsonin the filetemplate_typeThe field is set for the entire template package. This means that once you choose a template type (such as adaptive or PC+mobile independent), all the template files in the template package should follow the corresponding design principles and template syntax.The AnQi CMS uses Django template engine syntax, and regardless of the template type you choose, you should use this syntax.For PC+mobile independent mode, although the file structure is independent, they still share the same template engine context.
Q3: I created a new template, but how can I enable it in the background?As soon as you create a new template,config.jsonthe file is configured correctly and placed in/templateUnder the directory, the system usually detects it in the "Template Design" or "Website Template Management" area of the background management interface.You can find your new template on this interface and set it as the currently used template by clicking the enable button.Under the hood, this will typically update the template'sconfig.jsonin the filestatusField is1while enabling other templates'statusfield to be set0.