As an experienced website operations expert, I am well aware of the importance of an efficient and flexible content management system (CMS) for website operations.AnQiCMS (AnQiCMS) stands out among many CMSs with its lightweight, efficient, and powerful customizability in the Go language.Today, let's delve into a seemingly insignificant file in the Anqi CMS template directory structure that actually plays a crucial role -config.jsonand how it cleverly influences the selection of website navigation templates.
config.json: The 'ID card' of the template and the core configuration.
In the Anqi CMS template system, each template theme has an independent directory, and the core of this directory contains a file namedconfig.jsonThe configuration file. You can understand this file as the "identity card" or "manual" of this template, which clearly describes the various basic properties and operational status of the template to the AnQiCMS system.
This document contains such items as the name of the template(name), package namepackage), version numberversion), description (description), author information(author/homepage/created)Metadata. This information is important, but it is more used for the display and identification of background management interfaces.The actual operation of the template, especially the two key fields that have a profound impact on the selection of the navigation template we are discussing today:template_typeandstatus.
statusThe field is simple and clear, its value determines whether the current template is in the "use" state. Only when a certain template'sstatusSet to1When in use, AnQiCMS will load and apply the template theme.This is like changing the skin of a website, only the selected skin will take effect.Once a template is activated, itsconfig.jsonother configurations, includingtemplate_typestart to take effect.
template_type: It indirectly affects the navigation layout key
Andtemplate_typeField, it isconfig.jsonIt affects the core of the navigation template selection. It defines the adaption type of the template, currently there are mainly three optional values:
0: Adaptive (Responsive)1: Code Adaptation2: Computer + Mobile (Separate PC + Mobile)
These three types directly determine where AnQiCMS will look in the 'drawer' for specific template files when rendering pages, including template fragments that carry navigation structures.
Whentemplate_typeSet to0When adaptive, it usually means that the entire website's interface layout adjusts automatically according to the screen size of the device accessing it.In this mode, the navigation bar is usually designed as a set of schemes, implemented with CSS and JavaScript to achieve responsive layout, such as displaying the full menu on the desktop, and automatically collapsing into a "hamburger" menu on mobile devices.The system will look for such as in the main template directorypartial/header.htmlThis is a public file that contains navigation logic.
However, whentemplate_typeis set to1Or (code adaptation)2When (computer + phone) are independent, the situation changes.Both of these modes mean that AnQiCMS needs to provide a set of independent template files for mobile devices.According to the document agreement, these mobile template files are usually stored in a directory named under the main template directorymobile/in the subdirectory.
Imagine if there is one in your main template directory.default/partial/header.htmlA file that may contain a wide-screen desktop navigation HTML structure. When youconfig.jsontotemplate_typeis set to1or2At this time, AnQiCMS will prioritize going todefault/mobile/partial/header.htmlto find the corresponding mobile navigation structure. Ifmobile/The file exists in the directory, the system will load it, thus presenting a completely different navigation layout for mobile users, such as a full-screen menu or a bottom navigation bar optimized for touch screen.
Therefore,config.jsonoftemplate_typeIt did not directly specify which navigation template file to use, but indirectly told AnQiCMS to find the structure file of the navigation template in which directory according to the device type.This selection mechanism allows developers to design different navigation structures for PC and mobile terminals based on different terminal needs, thereby optimizing the user experience.
Collaboration between navigation data and template rendering
It is worth noting that,config.jsonandtemplate_typewhich affectsHTML structure template file for navigationfor examplepartial/header.htmlormobile/partial/header.html). The actual content displayed in the navigation menu (such as "Home", "Product Center", "About Us" and other links and text) is managed by the "Website Navigation Settings" function of the Anqi CMS backend.
In these structure template files, developers will use the built-in template tags of Anqi CMS, such as{% navList navs %}, to dynamically obtain navigation data from the database. This tag can be used totypeIdParameters (for exampletypeId=1Represents the main navigation,typeId=2Represents the footer navigation) to call the different navigation group data configured on the backend.
Therefore, the navigation effect presented to the user is,config.jsonThe result of the collaborative work of the defined template type, the HTML structure file under the template directory, and the navigation data configured in the background.config.jsonThis is the starting point of this collaboration, it lays the foundation for the presentation of navigation, determining what type of 'container' the navigation layout is.
Summary
In summary, under the Anqi CMS template directory,config.jsonThe file passes through itsstatusThe field activates a specific template theme and throughtemplate_typeThe field indicates the system in the desktop or mobile template directory (such asmobile/) look for the corresponding structure file. This indirect but crucial impact enables website operators and developers to flexibly provide customized navigation experiences for users on different terminals. Understand.config.jsonThe function, is to make full use of Anqi CMS for website content operation and template customization the first step.
Frequently Asked Questions (FAQ)
1.config.jsonoftemplate_typeHow does it specifically affect mobile navigation?
Answer:config.jsonoftemplate_typefield(value1or2Tell AnQiCMS that this template theme supports an independent mobile page structure. When users access it through mobile devices, the system will prioritize the template directory undermobile/Looking for the corresponding template file in the subdirectory, for examplemobile/partial/header.htmlIfmobile/If this file exists in the directory, it will be loaded and use a navigation HTML structure completely different from the desktop version. Iftemplate_typeIs0(Adaptive), it will not go specifically tomobile/The directory search, but the desktop and mobile end share a set of responsive design navigation structure.
2. Can I use multiple sets of navigation layouts in the same template, such as a top navigation and a footer navigation?config.jsonWill this choice affect?
Yes, you can.config.jsonThe main influence is on the overall template type (adaptive, code adaptation, or PC + independent mobile), as well as the system searching for navigation structure files (such aspartial/header.htmlThe position. The actual navigation menu content and grouping are configured in the 'Website Navigation Settings' of the AnQiCMS backend.You can create multiple navigation categories (such as "top navigation", "footer navigation"), and then in your template file, through{% navList navs with typeId=1 %}and{% navList footerNavs with typeId=2 %}tags, according to differenttypeIdThe parameters, each call and render this navigation data.config.jsonIt will not directly affect which one you call.typeIdnavigation data, but it affects where these navigation data are finally rendered in the HTML structure file.
3. If I changeconfig.jsonFile, what do I need to do to make the change take effect?
Answer: When you have modifiedconfig.jsonFile, especially involvingstatusortemplate_typeThis type of core configuration usually requires clearing the AnQiCMS system cache and restarting the application to make the changes take full effect. The system will read when it starts.config.jsonTo determine the current template and its operation mode. You can find options such as 'Update Cache' or similar in the background management interface. In some deployment environments