In the daily use of AnQiCMS (AnQiCMS), the flexibility of templates is one of the key factors in improving content operation efficiency.For many website administrators, how to make specific content - whether it is an article, a product, a category page, or an independent single page - have a unique display style while avoiding cumbersome repetitive configuration is a common need.AnQi CMS solves this problem well through a clever default custom template naming mechanism, allowing content operations and front-end design to collaborate efficiently.

AnQiCMS template management basics

The AnQiCMS template system is developed based on Go language, using.htmlfiles as templates, and stored in a unified manner./templateUnder the directory. Its syntax is similar to the Django template engine, using double braces{{变量}}To output data, using single braces and the percent sign{% 控制结构 %}To implement logical control. This design makes template development intuitive and easy to learn.The system also supports adaptive, code adaptation, and various template types such as PC+mobile independent sites, providing a solid foundation for content display on different devices and scenarios.

Fine-grained control: The magic of the default custom template name

One of the most remarkable features of AnQiCMS is that it can automatically identify and apply templates based on specific naming rules.This means that for some pages that require personalized display, we do not need to manually select a template in the background. Just create a template file according to the agreed format, and the system can automatically match and apply it.This 'configuration by convention' design greatly simplifies the workflow, especially suitable for websites with large content volume and high customization requirements.

In particular, Anqi CMS supports several important default custom template names:

  • Document detail page (article/product)If you want a unique detail page layout for a specific article or product, you can create an HTML file named after the document ID in the folder of its model. The naming format is:{模型table}/{文档id}.htmlFor example, if there is a document of an article model with an ID of123and the table name of the article model isarticlethen you can create a filearticle/123.html. When a user accesses this ID of the article,123the article, AnQiCMS will automatically load and usearticle/123.htmlas its detail page template.
  • Category list pageSometimes, we may want a specific category (such as "Latest News" or "Special Offers") to have a unique display style on its list page.AnQiCMS allows you to create a dedicated list template for a specified category ID.Naming format is:{模型table}/list-{分类id}.htmlFor example, if your product model table name isproductand you want the ID to be5The product category displays different list styles, you can create a fileproduct/list-5.html. When the user visits the product category ID of5the page, the system will automatically enable this custom template.
  • a single page detail pageFor pages such as "About Us" and "Contact Information", personalized design is also important.AnQiCMS also provides a default template mechanism based on ID for single-page.Naming format is:page/{单页面id}.htmlFor example, if your "About Us" page ID is7you can create a filepage/7.html. AnQiCMS will prioritize and apply when rendering this single page.page/7.html.

Flexible hierarchy and priority

AnQiCMS follows a clear priority rule in template selection, ensuring both automation and the highest degree of customization:

  1. The template is manually specified in the backgroundThis is the highest priority. If you specify a template file when editing documents, categories, or single pages in the background (for example, in the "Document Template" or "Category Template" fields, fill inspecial-download.html), then the system will always use this specified template, regardless of whether there is a template that matches the default naming rules.
  2. Default ID Naming Template: Next is the one mentioned above, according to{模型table}/{文档id}.html/{模型table}/list-{分类id}.htmlorpage/{单页面id}.htmlThis format-named template. If it exists and the background has not manually specified a template, the system will automatically apply it.
  3. General templateIf neither of the above two templates exist, AnQiCMS will fall back to a more general template. For example, for all article detail pages, it will look for{模型table}/detail.html(such asarticle/detail.html);for all category list pages, it will search{模型table}/list.html(such asarticle/list.html);for all single pages, it will searchpage/detail.html.

This hierarchical design allows website managers to flexibly choose between using a general template, customizing a template for a specific ID, or explicitly specifying a dedicated template through the backend.

Empower website operation: the balance of efficiency and customization

The default custom template naming mechanism of AnQiCMS brings significant advantages to website operation:

  • Improve efficiencyFor scenarios where only a small number of contents require special design among a large amount, there is no need to frequently enter the background to select templates, just create a file.
  • Refined customizationAllow each key content or page of the website to be visually and functionally customized at the pixel level without interfering with each other.
  • simplify managementThe template file naming follows a regular pattern, which allows front-end developers and content operators to more clearly understand the purpose and relevance of the template, reducing maintenance costs.
  • optimize user experience:Provide a more fitting display method for content of different types or importance, indirectly improving user experience and conversion rate.

In summary, AnQiCMS combines smart default naming conventions with flexible backend configurations to provide users with an efficient and highly customizable content management solution, allowing website operators to focus more on the content itself rather than on the繁琐 technical details.


Frequently Asked Questions (FAQ)

Q1: If a category or document has both a default naming template (such asarticle/list-5.html) and a manually specified template in the background, which one will AnQiCMS prioritize?

A1:In AnQiCMS, the template manually specified in the background has the highest priority.If a category, document, or single page explicitly specifies the template file to be used in the background editing interface, the system will load and apply this manually specified template unconditionally, without searching for or using any templates that match the default naming rules.This design ensures that operations personnel have absolute control over a specific page.

Q2: The default custom template naming rule includes{模型table}What does that mean? Where can I find this name?

A2: {模型table}It refers to the table name of the content model in the database, as well as the identifier of the content model in the template system. AnQiCMS built-in "article model" and "product model", their model table names are usuallyarticleandproduct(The specific name can be viewed or customized in the background "Content Management" -> "Content Model").If you create other custom content models, the model table name also needs to follow this rule.For example, a custom model named "news" may have its table name set tonews.

Q3: In addition to naming templates by ID, can I set a generic default template for all articles or all categories in AnQiCMS?

A3:Yes, AnQiCMS supports setting common templates for all articles (or all documents under a specific model) and all categories. These common templates are usually named{模型table}/detail.htmlAnd it is used for all document detail pages{模型table}/list.htmlAnd it is used for all category list pages. For example,article/detail.htmlAnd it will serve as the general detail page template for all articles.product/list.htmlIt will serve as the common list page template for all product categories. These common templates have a lower priority than manually specified templates and default templates named by ID.