What is the template file structure and naming convention of AnQiCMS?
As an experienced website operator who deeply understands the operation of AnQiCMS, I know that the foundation of content presentation lies in its flexible and standardized template system.A deep understanding of the template file structure and naming conventions of AnQiCMS is crucial for efficient management of website content, achieving personalized display, and ensuring system stability.The following will elaborate on the template design principles of AnQiCMS.
The AnQiCMS template system aims to provide high customizability and ease of use.The core lies in a clear directory structure and a set of Django-style template syntax.All template files are stored in the root directory of the application/templateIn the folder. Each independent template theme, or a complete website skin, will have its own dedicated subdirectory, for example/template/defaultThis topic subdirectory must also contain oneconfig.jsonConfiguration file.
config.jsonFiles are an important basis for AnQiCMS to recognize and manage templates, which contains the metadata of the template. For example,nameThe field defines the display name of the template,packagespecified the template folder name,versionmarked the version number,descriptionprovided a brief description,authorandhomepagethen indicated the author and website. In addition,createdrecorded the template creation time,template_type(Optional values are 0 for adaptive, 1 for code adaptation, 2 for computer and mobile) defines the response mode of the template, andstatus(0 disabled, 1 in use) indicates the current enabled status of the template. It should be noted that only one template can be in use at a time.
In terms of template file suffixes, AnQiCMS uniformly adopts.html. The template syntax is greatly influenced by the Django template engine, and variable calls use double curly braces, for example{{变量}}Where conditional statements, loop controls, and other logical tags are used in the form of single curly braces combined with percentage signs, for example{% if 条件 %}...{% endif %}These tags must appear in pairs, with clear start and end tags. All template files must use UTF-8 encoding to avoid compatibility issues such as garbled pages.
AnQiCMS supports various website modes in template design to adapt to different terminal devices.This includes adaptive templates, code adaptation templates, and PC + mobile independent site modes.If you choose the last two modes, especially the PC + mobile independent site mode, developers need to create a named directory under the main template directorymobile/The subdirectory is used to store exclusive template files for mobile devices.mobile/The file structure and naming conventions within the directory are consistent with the PC template.
AnQiCMS provides two main template file organization modes:
A folder organization pattern is a recommended, structured method that categorizes template files through multiple directories: At the top level,bash.htmlCommonly used to store common code snippets of a website, such as headers, footers, etc., which can be referenced in other templates.partial/The catalog is used to store smaller code snippets, such as sidebars, breadcrumb navigation, etc. The home page of the website is usually composed byindex/index.htmlDefine. For different content models (such as articles, products), there will be corresponding model home page templates, named in the format of{模型table}/index.html. The general template for content detail pages is{模型table}/detail.htmlAlso, you can create a dedicated template for documents with a specific ID, such as{模型table}/detail-{文档ID}.htmlSimilarly, the content list page has{模型table}/list.htmland for specific categories{模型table}/list-{分类ID}.html. Other functional pages includecomment/list.html(Comment list),guestbook/index.html(Online留言),page/detail.html(Single page details), as well as for a specific single page IDpage/detail-{单页ID}.html. Search page issearch/index.html, the tab page hastag/index.htmlandtag/list.html. Error page such aserrors/404.html/errors/500.htmlas well as the site shutdown prompt pageerrors/close.htmlAlso follow this pattern.
Flattened file organization mode is more concise, it places most template files directly under the theme root directory, distinguishing different types of pages through underscores in file names: common codebash.htmland code snippets directorypartial/The usage is the same as the folder organization mode. The homepage of the website is namedindex.html. The homepage of the model uses{模型table}_index.htmlformat (for examplearticle_index.html). The content detail page and the list page correspond to{模型table}_detail.htmland{模型table}_list.html. Other functional pages such ascomment_list.html/guestbook.html/page.html(Single page details, can also havepage-{单页ID}.html)、search.html/tag_index.html/tag_list.htmland error pageserrors_404.html/errors_500.html/errors_close.htmlall use flat naming conventions.
An