Default display template file for article detail page

Calendar 👁️ 65

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)

  1. 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.
  2. 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:

    1. The template specified in the "Document Template" field on the article editing page.
    2. Template file named according to the article ID (for examplearticle/detail-123.html)
    3. The document template set for the article category
    4. Template file for the general detail page of the model (for examplearticle/detail.htmlThis mechanism ensures that you can perform precise template control at different levels.
  3. 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 templatemobileThe 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.

Related articles

Which is the default display template file for the home page?

The homepage, as the first impression for users visiting your site, is of great importance.It carries multiple functions such as brand image, core information display, and user guidance.For those who are using or planning to use AnQiCMS (AnQiCMS) to build websites, understanding which file is behind the scenes controlling the display of this key page is the first step in customization and content optimization. AnQi CMS is committed to providing an efficient, customizable content management solution, naturally also providing you with great freedom to control this core page. Then

2025-11-08

How to embed reusable display components such as sidebars or breadcrumbs in a page?

In website operation, building an efficient and easy-to-maintain website is the key to success.AnQiCMS (AnQiCMS) is well aware of this, providing a flexible template mechanism that allows us to easily embed reusable display components on the page, such as sidebars and breadcrumb navigation.This modular method not only improves development efficiency, but also ensures the consistency of the overall style of the website and future maintainability.This article will delve into how to effectively create and embed these important reusable components using the template system in AnQiCMS.##

2025-11-08

How to reuse header, footer and other common display elements in AnQiCMS templates?

In website operation, efficiency and consistency are the key to success.When you manage a website, you will find that many elements appear repeatedly on different pages, such as headers, footers, navigation bars, sidebars, and so on.If you copy and paste this code manually every time, it is not only inefficient but also prone to errors, not to mention the cumbersome task of adjusting each one individually during subsequent modifications.Fortunately, AnQiCMS's template system is designed to be very flexible, providing powerful mechanisms to help us efficiently reuse these common display elements, ensuring the uniformity of the website style and making maintenance easier.

2025-11-08

How does the `template_type` setting in `config.` affect the overall display mode of the website?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides great convenience to our users.During the process of building and operating a website, there is a core configuration file called `config.`, which plays a vital role in each template directory.

2025-11-08

How to accurately extract the specified position element of a string in Anqi CMS template?

In AnQiCMS template development, we often need to flexibly handle text content, such as extracting the first few words of a long description as a summary, or extracting a specific part of the filename.AnQiCMS's powerful template engine provides a variety of practical filters (filter) to meet these needs, among which the "slice" filter is a powerful tool for precise string truncation.It allows us to easily extract any segment of content we want from a string or array.

2025-11-08

How to extract elements from a specified range in AnQi CMS template?

In the powerful template system of Anqi CMS, we often need to precisely control the display of content.Whether it is an article list, product album, or custom data model, data is often presented in the form of an array.Sometimes, we may only need to display a part of the array, such as only showing the latest three records, or picking out a few images from a picture list.At this point, the `slice` filter provided by AnQi CMS comes in handy, as it helps us elegantly extract elements within a specified range from the array

2025-11-08

How to get only the first N characters of a string using the `slice` filter?

In website content display, we often need to truncate a part of the long text as a preview, abstract, or to ensure the neat layout of the page.For example, it is crucial to control the text length precisely when displaying the article summary on the article list page or setting `meta description` content for search engine optimization (SEO).AnQiCMS (AnQiCMS) powerful template engine provides a variety of flexible filters to help us easily meet these needs.

2025-11-08

How to use `slice` to get the last N elements of an array in AnQiCMS template?

In AnQiCMS template development, we often need to handle list or array type data, such as article lists, product lists, and so on.Sometimes, we might only be concerned with a part of these data, such as the latest few articles, or a specific number of elements at the end of the list.At this time, the `slice` filter built into AnQiCMS is particularly powerful and convenient.It allows us to flexibly extract elements from an array or string within a specified range.This article will thoroughly introduce how to use the `slice` filter in AnQiCMS templates

2025-11-08