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 basis for efficient content management and personalized customization.
Firstly, the template files for Anqi CMS are uniformly stored in/templatethe directory and use.htmlAs a file extension. It uses a syntax similar to the Django template engine, through double curly braces{{变量}}To output data, using single braces and the percent sign{% 标签 %}Define logic and call function 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.htmlThis means that if your article belongs to the "article model" (usually corresponding to the model table namearticle), then the system will default to attempting to load/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 common detail page layout.
However, relying solely on model-level general templates often cannot meet all the needs of personalized display. Anqi CMS provides more detailed customization options for this:
A common way of personalization isspecified by document ID to specify the template. You can create a named{模型table}/detail-{文档ID}.htmlThe template file. For example, if you have an important article with an ID of '123' and you want it to have a unique page layout, you can create/template/您的模板目录/article/detail-123.html. When the user accesses this specific article, the system will load this more targeted template first.
Moreover, the Anqi CMS backend management interface also grants content operators the right to directly control the template. When editing articles, you will find a named “Document TemplateThe field name. Here you can directly fill in a custom template file name, for examplespecial_news_layout.htmlThen the system will go to/template/您的模板目录/Find and use this file. This method has the advantage of not needing to remember complex naming rules, and can directly specify any template file for a single article.
It is worth mentioning that the article'sThe category can also be set to the default document templateThis means that you can specify a default template file for all articles under a specific category (such as the "Industry News" category), for example,category_news_detail.html. Articles in this category will use this category template when no independent template is specified.Of course, if a single article manually specifies a "document template" during editing, then the article-level settings take precedence over the category-level settings.
In terms of 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 one in the root directory of the templatemobileSubdirectory. Then, inmobileIn the directory, store the mobile template files according to the same directory structure and naming conventions as the PC end, for example/template/您的模板目录/mobile/article/detail.htmlor/template/您的模板目录/mobile/article/detail-123.html.
On the design of template content, the tag function of Anqi CMS makes it extremely convenient to obtain and display data. For example,{% archiveDetail with name="Content" %}tags can directly obtain the detailed content of the article, and{{archive.Title}}It can conveniently output the article title.配合prevArchiveandnextArchiveTags can easily achieve navigation between articles,archiveParamsTags can help you display custom fields of articles, all of which greatly simplify the development and maintenance of templates.
By means of the above mechanism, Anqi CMS ensures that the article detail page can be flexibly managed and customized at multiple levels such as default general, specific ID, manual specification in the background, and classification setting, thereby meeting the diverse needs of content display.
Frequently Asked Questions (FAQ)
How can I set a unique template file for a specific article on my website (for example, a special article with ID "500")?Answer: You can achieve this in two main ways:
- File naming conventions:Find or create the corresponding model folder under your template directory (for example),
article), then createdetail-500.htmlFile. The system will prioritize loading this file when accessing the article with ID 500. - Back-end settings:When editing this article on 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, make sure thismy_special_page.htmlThe file exists in the root directory of your template, and the article will use it to display.
- File naming conventions:Find or create the corresponding model folder under your template directory (for example),
Ask: If my website has multiple default templates at the same time (such as general models for ...
detail.htmlWhich template will the AnQi CMS load first to display the article detail page, specified by category or named by article ID?Answer: AnQi CMS will follow a priority order from the most specific to the most general:- The template specified in the "Document Template" field on the article editing page.
- Template file named according to the article ID (for example
article/detail-123.html) - The document template set for the article category
- Template file for the general detail page of the model (for example
article/detail.htmlThis mechanism ensures that you can perform precise template control at different levels.
Ask: Can I set completely different templates for the PC and mobile versions of the article detail page?Yes. If your website template type is set to 'Code Adaptation' or 'PC + Mobile Independent Site' mode, you can create a file named in the root directory of the template
mobileThe folder. Then, inmobileInside the 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 the user is accessing.