How to create default templates for the model home page, document detail page, and list page of AnQiCMS?

Calendar 👁️ 48

As an experienced CMS website operation person, I know the importance of a clear and efficient template system for website content management.AnQiCMS provides a highly flexible and customizable template mechanism, allowing us to easily create personalized page layouts based on different business needs.Mastering the creation method of its default template is the foundation of efficient operation and content optimization.

This article will elaborate on how to create default templates for the model homepage, document detail page, and list page of AnQiCMS, along with the usage instructions for key tags to ensure that the content is presented accurately and without error to the user.

AnQiCMS Template System Overview

AnQiCMS template system aims to provide a simple and powerful content display capability. It uses a syntax similar to the Django template engine, and it uses.htmlThe file is used as a template and is placed uniformly in the root directory of the website./templateAll styles, JavaScript scripts, images, and other static resources are stored independently in the folder./public/static/Catalog. Understanding this separation is the first step in template creation.

The template file is stored in AnQiCMS using UTF-8 encoding, which ensures the correct display of multilingual content.The system also supports adaptive, code adaptation, and three types of PC+mobile template types to meet the needs of different device access.To enhance development efficiency, AnQiCMS defines some default template naming conventions. As long as files are created according to these conventions, the system can automatically recognize and apply them, saving the step of manual configuration in the background.

Create the default template for the model homepage.

The model homepage is a page that displays an overview of specific content models, such as 'Article Center' or 'Product Display'. Its default template file name convention is{模型table}/index.htmlor in flat mode, for{模型table}_index.html. Here,{模型table}Is the model table name specified when you define the content model in the background, for examplearticleorproduct.

In the model homepage template, we usually display the category list under the model, the latest released documents, or some recommended content.To achieve this, we can make use of the powerful template tags provided by AnQiCMS.

You can use{% moduleDetail %}Label to retrieve information about the current model, such as the title and description. This helps display the model name at the top of the page. Next,{% categoryList %}The label can be used to list all top-level categories or child categories of a specified parent category, allowing users to easily navigate to the category page of interest. For displaying the latest or recommended documents,{% archiveList %}Tags are an ideal choice, they can flexibly retrieve and display document lists based on model ID, recommended attributes (flag), or sorting method.For example, you can configure it to display the ten latest published articles or products with the 'Recommended' tag.

{# 示例:模型首页模板 - article/index.html #}
{% extends 'base.html' %} {# 继承基础布局,如包含头部和底部 #}

{% block title %}
    <title>{% moduleDetail with name="Title" siteName=true %}</title>
{% endblock %}

{% block content %}
    <div class="model-header">
        <h1>{% moduleDetail with name="Title" %}</h1>
        <p>{% moduleDetail with name="Description" %}</p>
    </div>

    <div class="category-navigation">
        <h2>内容分类</h2>
        <ul>
            {% categoryList categories with moduleId=archive.ModuleId parentId="0" %}
                {% for item in categories %}
                    <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
                {% empty %}
                    <li>当前模型下没有分类。</li>
                {% endfor %}
            {% endcategoryList %}
        </ul>
    </div>

    <div class="latest-documents">
        <h2>最新文档</h2>
        <ul>
            {% archiveList archives with moduleId=archive.ModuleId type="list" order="id desc" limit="10" %}
                {% for item in archives %}
                    <li>
                        <a href="{{ item.Link }}">
                            <h3>{{ item.Title }}</h3>
                            <p>{{ item.Description }}</p>
                            <span>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                        </a>
                    </li>
                {% empty %}
                    <li>暂无最新文档。</li>
                {% endfor %}
            {% endarchiveList %}
        </ul>
    </div>
{% endblock %}

Create the default template for the document detail page

The document detail page is a page to display the complete content of a single document. The default template file name is{模型table}/detail.htmlor in flat mode, for{模型table}_detail.html. This template is the core content display area of the website, which needs to fully and richly present document information.

In the document detail page,{% archiveDetail %}Tags are indispensable, as they can obtain all the detailed information of the current document, includingTitle(Title),Content(Content),Description(Description),Logo(Cover main image),Thumb(thumbnail),CreatedTime(Creation time) as well as all custom fields. You need to use|safea filter to ensure that the HTML code in the document content is rendered correctly, rather than being escaped and displayed.

In addition to the core content, we will also use{% categoryDetail %}tags to display the information of the current document category,{% prevArchive %}and{% nextArchive %}Tags are used to provide navigation links between documents, enhancing the user's browsing experience. If you need to display related documents,{% archiveList archives with type="related" %}Tags can automatically search and list other content related to the current document. In addition,{% commentList %}Tags are used to display and manage comments by users on the current document.

{# 示例:文档详情页模板 - article/detail.html #}
{% extends 'base.html' %} {# 继承基础布局 #}

{% block title %}
    <title>{% tdk with name="Title" siteName=true %}</title>
{% endblock %}

{% block content %}
    <article class="document-detail">
        <h1>{% archiveDetail with name="Title" %}</h1>
        <div class="meta-info">
            <span>分类:<a href="{% categoryDetail with name='Link' %}">{% categoryDetail with name='Title' %}</a></span>
            <span>发布日期:{% archiveDetail with name="CreatedTime" format="2006-01-02 15:04" %}</span>
            <span>浏览量:{% archiveDetail with name="Views" %}</span>
        </div>

        <div class="document-content">
            {%- archiveDetail documentContent with name="Content" %}
            {{ documentContent|safe }}
        </div>

        {# 自定义字段展示示例,假设有一个名为“author”的自定义字段 #}
        {% archiveDetail articleAuthor with name="author" %}
        {% if articleAuthor %}
            <div class="document-author">作者:{{ articleAuthor }}</div>
        {% endif %}

        <div class="navigation-links">
            {% prevArchive prev %}
                {% if prev %}
                    <a href="{{ prev.Link }}">上一篇:{{ prev.Title }}</a>
                {% else %}
                    <span>没有上一篇了</span>
                {% endif %}
            {% endprevArchive %}

            {% nextArchive next %}
                {% if next %}
                    <a href="{{ next.Link }}">下一篇:{{ next.Title }}</a>
                {% else %}
                    <span>没有下一篇了</span>
                {% endif %}
            {% endnextArchive %}
        </div>

        <div class="related-documents">
            <h2>相关文档</h2>
            <ul>
                {% archiveList relatedDocs with type="related" limit="5" %}
                    {% for item in relatedDocs %}
                        <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
                    {% empty %}
                        <li>暂无相关文档。</li>
                    {% endfor %}
                {% endarchiveList %}
            </ul>
        </div>

        <div class="document-comments">
            <h2>评论</h2>
            {% commentList comments with archiveId=archive.Id type="list" limit="10" %}
                {% for item in comments %}
                    <div class="comment-item">
                        <strong>{{ item.UserName }}</strong> @ {{ stampToDate(item.CreatedTime, "2006-01-02 15:04") }}
                        <p>{{ item.Content }}</p>
                    </div>
                {% empty %}
                    <p>暂无评论。</p>
                {% endfor %}
            {% endcommentList %}
            {# 这里可以加入评论表单 #}
        </div>
    </article>
{% endblock %}

Create the default template for the document list page

The document list page is used to display a series of documents, which is usually filtered by category and paginated. The default template file name is{模型table}/list.htmlor in flat mode, for{模型table}_list.html.

The core of the document list page template is{% archiveList %}Label, but different from the model homepage, here we need totypethe parameter topage, and setlimitcontrol the number of documents displayed per page, thus enabling pagination. Together{% pagination %}Label, can generate a complete page navigation.

{% categoryDetail %}The tag can be used to get detailed information about the category to which the current list belongs, such as the category title, description, or Banner image, so that the featured content of the category can be displayed at the top of the page.{% categoryList %}Labels can be used to display the subcategories or sibling categories of the current category, making it convenient for users to switch between category levels. If your content model supports complex filtering criteria,{% archiveFilters %}The tag can automatically generate filter options based on custom document parameters, greatly enhancing the user experience.

”`twig {# Example: Document list page template - article/list.html #} {% extends ‘base.html’ %} {# Inherit base layout #}

{% block title %}

<title>{% tdk with name="Title" siteName=true %}</title>

{% endblock %}

{% block content %}

<div class="list-header">
    <h1>{% categoryDetail with name="Title" %}</h1>
    <p>{% categoryDetail with name="Description" %}</p>

Related articles

What is the naming convention for the default homepage template file in AnQiCMS?

As an experienced CMS website operation personnel of an enterprise, I know that the naming specification of template files is crucial for the smooth operation and efficient management of the website.A clear naming convention not only ensures that the system renders the page correctly, but also greatly improves team collaboration and post-maintenance efficiency.Below, I will elaborate on the naming rules of the default home page template files in Anqi CMS.In AnQi CMS, all template files are stored in the `/template` folder under the system root directory.Each independent website template will be in `/template`

2025-11-06

How to create and reference reusable code snippets (such as sidebars) in AnQiCMS templates?

As an experienced CMS website operation personnel of a security company, I know that efficiency and maintainability are the key to website content management in daily work.AnQiCMS provides a powerful and flexible template system, where creating and referencing reusable code snippets is an important means to improve these aspects of efficiency.This not only reduces repetitive labor, but also ensures the consistency of the overall style and function of the website, and also lays a solid foundation for future content updates and website renovations.

2025-11-06

How does the AnQiCMS template organize common code (such as header and footer)?

As an experienced CMS website operation personnel of an enterprise, I know that efficient content management cannot do without a well-organized and easy-to-maintain template system.In AnQi CMS, to better manage the public code of the website, such as the header (Header) and footer (Footer), the system provides a clear template organization structure and powerful template engine features.This not only improves the development efficiency, but also ensures the consistency and maintainability of website content.

2025-11-06

What do the two states represent for the `status` field in `config.`?

In AnQiCMS (AnQiCMS) template management system, the `config.` file plays a crucial role, acting like an ID card for the template, recording all basic information and current status of the template.The `status` field is the key indicator used by the system to identify whether a template is activated and in use.This field has only two possible values, each representing different meanings and uses, which are crucial for the normal operation of the website and the flexible management of templates.### Status 1: `status: 0`

2025-11-06

What is the default naming rule for single page detail page templates in AnQiCMS?

As an experienced CMS website operator for an enterprise, I am well aware that the exquisite presentation of content lies in the flexible application of templates.AnQiCMS as an efficient and customizable content management system provides us with powerful tools to shape every detail of the website, including the layout and style of single-page detail pages.Understanding the template naming rules is the foundation for efficiently managing and optimizing website content.

2025-11-06

How to use a custom template for specific documents, categories, or single pages in AnQiCMS?

As an experienced AnQiCMS (AnQiCMS) website operations personnel, I am well aware of the importance of content in attracting and retaining users, and the flexible template system is the key to achieving personalized content display.AnQiCMS provides powerful custom template features, allowing operation personnel to create unique page layouts and styles according to different content needs.### AnQiCMS Template Working Principle Overview AnQiCMS template system is based on Go language and adopts syntax similar to Django template engine, files are in the form of `

2025-11-06

What template engine syntax does AnQiCMS template support, and what are the formats of its variables and tags?

As an experienced AnQiCMS website operations personnel, I am well aware of the importance of an efficient and easy-to-use template system for website content management and user experience.AnQi CMS does an excellent job in this aspect, providing a powerful and flexible template mechanism that makes content presentation intuitive and highly customizable.Now, let's delve deeper into the syntax, variables, and tag formats supported by the AnQiCMS template.

2025-11-06

How to get and display the website name and logo in AnQiCMS template?

As an experienced CMS website operation personnel of an enterprise, I am well aware of the importance of effectively displaying brand information in templates for user experience and brand recognition.The following article will provide a detailed guide on how to obtain and display the website name and logo in the AnQiCMS template.In AnQiCMS template, a practical guide to obtaining and displaying the website name and LogoThe website's name and logo are the core visual elements of the brand

2025-11-06