As an experienced website operations expert, I fully understand the importance of a flexible and powerful content management system for enterprises.AnQiCMS is a top-notch platform committed to providing efficient and customizable solutions.config.jsonIt plays a crucial role. It not only defines the basic attributes of the template but also profoundly affects the behavior and performance of the template in the system.

AnQiCMS template's "Identity Certificate":config.jsonParsing

Under the AnQiCMS template root directory, you will find a file namedconfig.jsonThe file.It is like the 'ID card' or 'instructions' of a template, through which the system identifies the template, understands its basic properties, and decides how to load and manage this template.config.jsonIt is the basis to ensure that the template can be recognized and run normally by the AnQiCMS system, and it is also the first step to achieve high customizability of the template.

Let's take a typicalconfig.jsonFor example, interpret the meaning and function of each field one by one in the file content:

{
	"name": "默认模板",
	"package": "default",
	"version": "1.0",
	"description": "系统默认模板",
	"author": "kandaoni.com",
	"homepage": "https://www.kandaoni.com",
	"created": "2022-05-10 22:29:00",
	"template_type": 0,
	"status": 0
}

Firstly, it is the metadata information of the template:

  • nameThis field defines the name displayed in the AnQiCMS admin interface, which is the most intuitive identifier.For example, you can name it "corporate website template" or "fashion blog theme" and so on, which is convenient for quick distinction among many templates.
  • package: Followed by the next one:packageThe field is more critical, as it represents the unique identifier of the template, usuallyit should be consistent with the name of the template folderFor example, if your template folder is calledmythemethenpackagethen you should fill inmythemeThis field only supports letters and numbers, please ensure its accuracy, as the system relies on it to locate template resources, and if it does not match, the template will not be recognized and used.
  • version: Used to record the template version.This is very helpful for iterative updates of templates and issue tracking, especially when engaging in secondary development or collaboration with others, clear version information can avoid a lot of confusion.
  • description: Provided a brief introduction to the template, allowing users to quickly understand the functions and features of the template. This content will be displayed in the background template management list, helping operators to make choices.
  • author,homepage,createdThese three fields, as the names suggest, are used to record the developer of the template, the developer's website, and the creation time of the template.This information not only reflects the developer's right of attribution, but also provides users with the convenience of contact and traceability.

In addition to this basic information,config.jsonit also includes the core configuration that determines the template behavior:

  • template_type: This is a very important setting, which determines how the template responds to user access from different devices. AnQiCMS provides three optional values:
    • 0(Adaptive)This means that the same HTML/CSS/JS code will automatically adjust the layout according to the screen size of the device being accessed.This is the mainstream responsive design method at present, development is relatively centralized.
    • 1(Code Adaptation)In this mode, you may need to prepare different CSS or JS logic for the PC and mobile ends, but still use the same template file (for example, by loading different style sheets based on the user agent).It is between adaptive and completely independent.
    • 2(PC + Independent Mobile)This is the most explicit separation mode, which requires you to create completely independent template directories for the PC and mobile ends. Typically, the mobile template is stored in the root directory of the template.mobileIn the subdirectory.The system will load the corresponding template based on the device type, which is very useful when it is necessary to provide completely different experiences for different devices. Choose the type, which directly affects the complexity of template development and the ultimate user experience, and determines the organization of your template files.
  • status: This field indicates whether the template is enabled:0Indicates that the template is not enabled,1The template is in use. It should be noted that in the AnQiCMS system, only one template can be used at any timestatusThe value of1That is, only one template can be enabled at a time. This is the core mechanism of the system for template switching and management.

In practice,