As an experienced CMS website operation personnel for an information security company, I know that a flexible and efficient template system is crucial for the presentation of website content and user experience.The AutoCMS was designed with full consideration of the customizability and ease of use of templates, allowing both beginners and experienced developers to easily handle it.config.jsonThe core role played by the file in this process.
To define a new template for the security CMS, it first needs to be done 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_designThis new folder is the basic location where all files of your new template are stored.
There is a crucial file in the root directory of the new template,config.jsonThis file is the 'ID card' and 'manual' of the template, informing the security CMS system of the basic information, type, and status of the template. It can be said that without itconfig.jsonFile, your new template cannot be recognized and loaded correctly by the system.
Let's understand it in detail.config.jsonThe roles of each field in the file:
in the filenameField used to specify the display name of the template, which is usually the name seen by the user in the background management interface, such as 'Default Template' or 'Corporate Website Style'.packageField is the unique identifier of the template, it corresponds to the/templatefolder name of the template created under the 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.homepageThe field can provide the author's website link.createdThe field records the creation time of the template, in such a specific format.2022-05-10 22:29:00The field records the creation time of the template, in such a specific format.
template_typeYesconfig.jsonAn extremely critical setting, which determines the adaptation mode of the template. Anqi CMS supports various adaptation modes, including0代表的自适应模式(模板在不同设备上自动调整布局),1代表的代码适配模式(需要为PC和移动端分别编写不同的HTML结构),以及2Representing the computer+mobile independent site mode (PC and mobile end have completely independent template files, and usually also cooperate with independent mobile end domain name).Select the appropriate template type to ensure your website provides a** good browsing experience on different devices.
Finally,status字段指示了模板的启用状态。其可选值为0(未启用)或1(In use)。It should be noted that only one template can be used among all the installed templatesstatusthe value is set to1, which means that only one template can be enabled at a time in Safe CMS.
Onceconfig.jsonThe file configuration is complete, and the next step is to build the specific file structure of the template.The company provided 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 based on their functions and content types, for example,index/index.htmlused for the homepage,{模型table}/detail.htmlUsed for document detail pages,partial/The directory stores reusable code snippets such as headers, footers, and sidebars. This structure helps maintain the clarity and modularity of template files.
Compared to this, the "flattened file organization mode" directly places all major template files in the root directory of the template, for exampleindex.htmlRepresents the homepage,{模型table}_detail.htmlRepresents the document detail page. This mode may be more suitable for small or simple website templates.
Regardless of which organizational mode you choose, if yourtemplate_typeSet to code adaptation or PC+mobile independent site mode, you need to create a directory under the template root.mobile/Subdirectory, and copy the mobile template files similar to the PC template structure. In this way, the Safe 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.htmlThe dedicated template, and associate it with the corresponding single page in the background management interface. This greatly enhances the flexibility of the template and the ability to personalize the display of content.
In short,config.jsonThe file is the starting point for defining a new template, it provides all the necessary information for the security CMS to identify, classify, and manage templates. By reasonable configurationconfig.jsonFollow the template organization conventions, and you will be able to fully utilize the powerful functions of Anqi CMS to build highly customized and user-friendly websites.
Frequently Asked Questions
Q1: If myconfig.jsonFile missing or misconfigured, how will the system handle it?Ifconfig.jsonFile missing or missing key fields (such as)packageornameThe configuration is incorrect, the security CMS system will not be able to correctly identify and load your template, which may cause the website to not display normally, or the template cannot be found in the background template management list.The system will usually revert to the default template or display an error message.config.jsonThe file always exists and is correctly configured is the premise for the normal operation of the template.
Q2: Can I use completely different template engines or syntax for PC and mobile in the same template folder?No.config.jsonin the filetemplate_typeThe field is set for the entire template package.This means that once you select a template type (such as, adaptive or PC+mobile independent), all template files within the template package should follow the corresponding design principles and template syntax.The AnQi CMS uses the Django template engine syntax, 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?The new template you created, as long asconfig.jsonThe file configuration is correct 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 current template by clicking the enable button.config.jsonin the filestatusthe field is1,while other templates are being modifiedstatusThe field is set to0.