Template Tags and Usage

Calendar 👁️ 1135

The use of template files is similar to the tag syntax of Django template engine, 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 need to be terminated with an end tag, appearing in pairs, such as{% if archive.Id == 10 %}这是文档ID为10的文档{% endif %}.

There are 38 commonly used tags built into the system:

  • System settings labelsystem
How to use: {% system variable name="field name" %}
  • Contact Information Tagcontact
Use method: {% contact variable name with name="field name" %}
  • Universal TDK tagstdk
How to use: {% tdk variable name with name="field name" %}
  • Navigation List TagnavList
How to use: {% navList navs %}...{% endnavList %}
  • Breadcrumb Navigation Tagbreadcrumb
Usage: {% breadcrumb crumbs with index="Home" title=true %}...{% endbreadcrumb %}
  • Category List LabelcategoryList
Usage method: {% categoryList categories with type="1" parentId="0" %}...{% endcategoryList %}
  • Category Details LabelcategoryDetail
Usage: {% categoryDetail with name="variableName" %}
  • Single-page list tagpageList
Usage: {% pageList pages %}...{% endpageList %}
  • Single page detail tagpageDetail
Usage: {% pageDetail with name="variable name" %}
  • Document List TagsarchiveList
Usage method: {% archiveList variable name with categoryId="1" moduleId=1 order="id desc|views desc" type="page|list" %}...{% endarchiveList %}
  • Document Details TagarchiveDetail
How to use: {% archiveDetail with name="variable name" %}
  • Previous Document TagprevArchive
How to use: {% prevArchive prev %}...{% endprevArchive %}
  • Next Document TagnextArchive
How to use: {% nextArchive next %}...{% endnextArchive %}
  • related document tagarchiveList
View the usage method in the document list label: {% archiveList archiveRelations with type="related" %}...{% endarchiveList %}
  • document parameter tagarchiveParams
{% archiveParams params with sorted=true %}...{% endarchiveParams %}
  • document parameter filter tagarchiveFilters
Usage method: {% archiveFilters params with moduleId=1 allText="All" %}...{% endarchiveFilters %}
  • Document Tag List LabeltagList
How to use: {% tagList tags with type="1" limit="10" %}...{% endtagList %}
  • Tag Details LabeltagDetail
Use method: {% tagDetail with name="variable name" %}
  • Tag Document List LabeltagDataList
How to use: {% tagDataList archives with tagId="1" %}...{% endtagDataList %}
  • Comment List LabelcommentList
How to use: {% commentList comments with itemType="archive" itemId="1" type="page" %}...{% endcommentList %}
  • Message Form Labelguestbook
How to use: {% guestbook fields %}...{% endguestbook %}
  • Friendship Links LabellinkList
Usage method: {% linkList friendLinks %}...{% endlinkList %}
  • Pagination Labelpagination
Usage method: {% pagination pages with show="5" %}...{% endpagination %}
  • if logical judgment tagif else endif
Usage method: {% if condition %} ... {% elif other conditions %} ... {% else %} ... {% endif %}
  • for loop traversal tagfor empty endfor
Usage method: {% for item in archives %}...{% empty %}...{% endfor %}
  • Formatted timestamp labelstampToDate
Usage method: {{stampToDate(timestamp, "format")}}.A timestamp that is 10 digits long, such as 1609470335, in the format supported by Golang.
  • Define variable assignment labelwith
How to use: {% with title="This is the title declared for the header" keywords="These are the keywords declared for the header" %} %} Title: {{title}}, Keywords: {{keywords}}
  • Other auxiliary labelstags
Use method: include, extends, macro, lorem
  • More filtersfilters
Usage method: {{obj|filter__name:param}}}

Related articles

Template Creation Directory and Template

The root directory of AnqiCMS template is /template, each template set needs to create its own template directory under /template, and add a config. configuration file in the template directory to specify some information about the template.The content format of the config. file is: { "name": "Default template", "package": "d"}

2022-06-07

Some basic conventions of template creation

AnqiCMS template, using .html as the template file suffix, and stored in the /template template folder. The styles, js scripts, images, and other static resources used by the template are stored separately in the /public/static/ directory.The use of template files is similar to the tag syntax of Django template engine, variables are defined using double curly braces, such as {{variable}}. Conditions

2022-06-07

Why Editing Templates in External Editors Does Not Take Effect

The template caching mechanism description: Anqi CMS adopts memory caching optimization strategy in the production environment (production): Preloading at startup: The template files are loaded into memory all at once when the service starts Rendering acceleration: The page requests directly read the memory template, avoiding repeated disk I/O operations Performance advantages: Reduce server load, improve web page response speed to milliseconds level Development modification注意事项 When modifying template files through external editors (Baota panel/VSCode, etc.): ✖ Modifications only affect disk files ✖ The memory cache template does not update automatically

2025-08-13