Some Basic Conventions of Template Creation

AnqiCMS templates, usage.htmlAs template file suffix, and stored in/templateIn the template folder, the static resources such as styles, JavaScript scripts, images, etc. used by the template are stored separately./public/static/directory.

The use of template files is similar to the tag syntax of Django template engine, and variables are defined using double curly braces, such as{{变量}}Condition judgment, loop control, and other tags are defined using single curly braces and percent signs, and they must be terminated with an end tag, appearing in pairs, such as{% if archive.Id == 10 %}这是文档ID为10的文档{% endif %}.

The variable name follows camelCase notation, with each word capitalized, except for some special provisions, such as{archive.Id}/{archive.Title}.

The template file is encoded in UTF-8 encoding uniformly. If it is encoded in another encoding, it will cause the page to display garbled text and cannot be displayed normally. If you are a Windows user editing the template file, please save it as a template file encoded in UTF-8 format.

The supported template types include: Adaptive template type, Code adaptation template type, PC + mobile template type.

Templates support separate mobile template definitions, and mobile templates are stored in:mobileWhen selecting the template for the code adaptation mode and PC+mobile mode, you need to createmobiletemplate.

The template supports some default custom names. As long as these custom template files exist, there is no need to set the template separately in the background, and the template can be applied automatically.

The supported template names are:

  • The default custom template name format for documents is:{模型table}/{文档id}.html
  • The default custom template name format for document lists is:{模型table}/list-{分类id}.html
  • The default custom template name format for single pages is:page/{单页面id}.html