The Anqi CMS provides a flexible and powerful template mechanism for handling the display of website article detail pages, allowing content operators and developers to finely control the presentation of each article according to actual needs.Understanding the default template file search logic is the foundation for efficient content management and customization.

Firstly, the template files of Anqi CMS are all stored in/templatedirectory, and use.htmlAs a file extension. It uses syntax similar to the Django template engine, through double curly braces{{变量}}to output data, through single curly braces and percentage signs{% 标签 %}Define logic and call feature tags. This design makes the template code easy to understand and expressive.

For the article detail page, Anqi CMS will search for and load the corresponding template files according to certain priority and naming conventions. The most common and basic default template file is located atModel directory underdetail.html. This means that if your article belongs to the "article model" (usually corresponding to the model table namearticle), the system will try to load it by default/template/您的模板目录/article/detail.htmlThis file. Similarly, if your content is 'product model', the system will search for/template/您的模板目录/product/detail.htmlThis design, which divides content by model, allows all content under the same model to share a set of common detail page layouts.

However, relying solely on model-level general templates often fails to meet all personalized display needs. AnQi CMS provides more detailed customization options for this.

An English translation for 'auto' is 'English'Specify the template through document ID. You can create one named{模型table}/detail-{文档ID}.htmlThe template file. For example, if you have an important article with ID "123", and you want it to have a unique page layout, you can create/template/您的模板目录/article/detail-123.htmlWhen the user accesses this specific article, the system will prioritize loading this more targeted template.

Additionally, the backend management interface of Anqi CMS also grants content operators the right to directly control the templates. When editing articles, you will find a name called “Document templateThe field enclosed in quotation marks. Here, you can directly enter a custom template file name, such asspecial_news_layout.html. The system will then go to/template/您的模板目录/Look for and use this file. The advantage of this method is that you do not need to remember complex naming rules, and you can directly specify any template file for a single article.

It is worth mentioning that thedefault 'Document Template' can also be set for the categoryThis means that you can specify a default template file for all articles under a specific category (such as the "Industry News" category)category_news_detail.html.This article will use the category template for this category when no independent template is specified.Of course, if a single article manually specifies a "document template" during editing, the article-level settings will take precedence over the category-level settings.

On mobile adaptation, Anqi CMS also considers it thoroughly. If your website template supports 'code adaptation' or 'PC + mobile independent site' mode, and you need to provide different article detail page layouts for mobile devices, you can create amobileSubdirectory. Then, inmobileIn the directory, store the mobile template files following the same directory structure and naming conventions as the PC端, for example/template/您的模板目录/mobile/article/detail.htmlor/template/您的模板目录/mobile/article/detail-123.html.

The tag feature of Aanqi CMS makes it exceptionally convenient to retrieve and display data in the template content. For example,{% archiveDetail with name="Content" %}tags can directly obtain the detailed content of the article,{{archive.Title}}It can conveniently output the article title. WithprevArchiveandnextArchiveTags can easily implement navigation between articles,archiveParamsTags can help you display custom fields of articles, all of which greatly simplify the development and maintenance of templates.

Through the above mechanism, the AnQi CMS ensures flexible template management and customization at multiple levels, including default general, specific ID, manually specified in the background, and classification setting, thereby meeting diverse content display needs.


Common Questions (FAQ)

  1. 问:How do I set a unique template file for a specific article on my website (for example, a feature article with ID “500”)?答:You can achieve it in two main ways:

    • File naming conventions:Find or create the corresponding model folder under your template directory (for examplearticle), then createdetail-500.htmlFile. The system will prioritize loading this file when accessing the article with ID 500.
    • Backend settings:When editing this article in the AnQi CMS backend, find the 'Document Template' field under 'Other Parameters', and directly enter the name of your custom template file (for example,my_special_page.html)。Then,ensure thismy_special_page.htmlThe file exists in your template root directory, and the article will use it to display.
  2. 问:If my website contains multiple default templates at the same time (such as model generic template)detail.htmlEnglish categorization specified document templates and templates named by article ID, which template will the secure CMS load first to display the article detail page?答:English CMS will follow a priority order from the most specific to the most general:

    1. The template specified in the “Document Template” field on the article editing page.
    2. Named template files according to article ID (for example)article/detail-123.html).
    3. The "Document Template" set for the category of the article.
    4. Model general detail page template files (for example)article/detail.html). This mechanism ensures that you can perform precise template control at different levels as needed.
  3. 问:Can I set completely different templates for the PC and mobile end of the article detail page?答:可以的。如果您的网站模板类型设置为“代码适配”或“PC+手机独立站点”模式,您可以在模板的根目录下创建一个名为mobileThe folder. Then, inmobilethe folder, following the same directory structure and naming conventions as the PC template (for examplemobile/article/detail.htmlormobile/article/detail-123.htmlCreate your mobile-specific template. The system will automatically load the corresponding PC or mobile template based on the type of device accessed by the user.