Hello!As an experienced AnQiCMS website operation person, I am very happy to share with you the key knowledge about AnQiCMS template creation in English.In my daily work, reasonable planning and accurate application of templates are the foundation for efficient content display and improved user experience.Deeply understand the basic conventions and directory structure specifications of AnQiCMS templates, which not only allows us to carry out content creation and publication more smoothly, but also lays a solid foundation for the long-term maintenance and optimization of the website.

Next, I will elaborate on the basic conventions and directory structure standards followed by AnQiCMS template creation, to help you better master this powerful tool.

Basic conventions for AnQiCMS template creation

Build and customize templates in AnQiCMS, you need to follow a series of clear conventions to ensure that the system can correctly parse and render your design.These conventions cover multiple aspects, from file formats, naming conventions to template engine syntax.

Firstly, all template files are unified using.htmlAs a file extension, and stored centrally under the website root directory./templateThe folder. In order to maintain the purity and ease of management of template files, the stylesheets, JavaScript scripts, and images, etc., that the template depends on should be stored independently./public/static/Contents, rather than within the mixed template file directory.

On template writing, AnQiCMS adopts syntax similar to Django template engine. This means you will use double curly braces to define and output variables, for example{{变量}}For more complex logic control, such as conditional judgment and loop traversal, use labels wrapped in single curly braces and percent signs, for example{% if 条件 %}These control flow tags usually need to appear in pairs, such as{% if ... %}need a corresponding{% endif %}to end.

The naming of variables also has its standards.In AnQiCMS template, variable names usually follow the camel case naming convention, and the first letter of each word needs to be capitalized.archive.Id/archive.Titlevariables in the form ofIdandTitleAll names start with an uppercase letter. This naming convention helps maintain consistency and readability of the code.

Moreover, the encoding format of the template file is crucial.AnQiCMS requires all template files to be encoded in UTF-8.If the template file uses other encoding formats, the page may display garbled characters when displayed, resulting in the content not being presented normally.Therefore, if you are editing template files in the Windows environment, please make sure to select UTF-8 encoding format when saving.

AnQiCMS supports various template types to meet different website design and access needs.This includes adaptive template types, code adaptation template types, as well as independent template types for PC and mobile phones.When you choose the code adaptation mode or PC+mobile mode, the system allows you to design a separate template for mobile devices.mobileIn the subdirectory, and its internal directory structure and file naming rules are consistent with the PC template.

To further enhance the flexibility and convenience of the template, AnQiCMS also supports some default custom template names.This means that as long as you create these template files following a specific naming format, the system can automatically recognize and apply them without any additional configuration in the background.{模型table}/{文档id}.htmlEnglish, the default template for document lists is{模型table}/list-{分类id}.htmlEnglish, the default template for single pages ispage/{单页面id}.htmlThis mechanism greatly simplifies the process of designing personalized templates for specific content or categories.

AnQiCMS template directory structure specification

Understanding the template directory structure of AnQiCMS is the foundation for efficient management and development of templates. All template-related files are stored in/templateAs the root directory, each independent template needs to have its own exclusive directory under this directory.

Within a template directory, there is a directory namedconfig.jsonThe configuration file is essential.This file carries the key information of the template, including the template name, package name, version, description, author, homepage, creation time, template type, and usage status.config.jsonThe field is mostly optional, but it is crucial for the identification and management of the template. For example,namefield is used to specify the display name of the template,packagefield represents the folder name of the template, whiletemplate_typethen specifies the responsive behavior of the template (0 for adaptive, 1 for code adaptation, 2 for PC+mobile). It is especially worth noting that,statusField (0 for disabled, 1 for in use) in an AnQiCMS installation can only have one template set as1the current template being used.

AnQiCMS provides two main template file organization modes to accommodate different development habits and project scales: folder organization mode and flat file organization mode.

InFolder organization modeBelow, template files are logically grouped and stored in different subdirectories:

  • Public code files, such as the website's header and footer, are usually named:bash.htmlfor inheritance and reference by other pages.
  • Reusable code snippets, such as sidebars, breadcrumb navigation, etc., are stored inpartial/In the catalog.
  • The homepage file of a website is usuallyindex/index.html.
  • There will be a model homepage for different content models, for example{模型table}/index.html.
  • Document details page can be{模型table}/detail.html, or for a specific document ID,{模型table}/detail-{文档ID}.html.
  • The document list page is similar, it is{模型table}/list.html, or for a specific category,{模型table}/list-{文档分类ID}.html.
  • The comment list page is usuallycomment/list.htmlOnline留言页为guestbook/index.html.
  • Single page detail page ispage/detail.htmlorpage/detail-{单页ID}.html.
  • Search results page, tag page, and error page also have their corresponding default positions, such assearch/index.html/tag/index.html/tag/list.html/errors/404.html/errors/500.htmlanderrors/close.html.
  • As previously mentioned, if the mobile template is enabled, the file structure will repeat the aforementioned pattern.mobile/The pattern mentioned above will be repeated in the directory.

whileFlat file organization modeThen place the file directly in the template root directory, and distinguish its function and module through the prefix or suffix of the file name. For example, the homepage isindex.html,model home page is{模型table}_index.html,document detail page is{模型table}_detail.htmlThis pattern simplifies the directory hierarchy, but requires file names to be more explicit and identifiable.

These organizational modes both allow for custom naming of some template files. This means that if you need to apply a unique template to a specific document, category, or single-page application, you can specify a custom template filename in the background settings (for example,)page/about.html),Only if the file exists in your template design package, the system can apply it to the corresponding page.This high degree of flexibility ensures that AnQiCMS can meet various personalized content display needs.

Frequently Asked Questions

1. Where can I find the detailed label usage document for AnQiCMS templates made?As an AnQiCMS operations staff, I know that template tags are the core of content display.The detailed usage methods and parameter descriptions of all template tags can be found in the "Template Creation" -u003e "Tags and Usage" and "Template Call Tags" sections of the AnQiCMS official documentation.Here is a comprehensive guide to 38 commonly used tags from system settings to document lists, category details, etc., which can help you efficiently build dynamic content pages.

2. What should I pay attention to when editing template files on the Windows system to avoid garbled characters?This is a common question.To ensure that your AnQiCMS website displays normally under different environments, the template files must be encoded in UTF-8.When editing on Windows system, please make sure to save the file in UTF-8 format.Most modern editors (such as VS Code, Sublime Text, Notepad++) support selecting encoding formats when saving. Please make sure you have selected the correct option to avoid page garbled text issues.

3. What types of template display modes does AnQiCMS support?AnQiCMS to meet the diverse needs of websites, provides three main template display modes: adaptive template type, code adaptation template type, and PC + mobile end template type.You can choose the most suitable mode based on the audience and design strategy of the website.mobilesubdirectory.