In the daily use of AnQiCMS, the flexibility of templates is one of the key factors to improve content operation efficiency.For many website administrators, the common need is 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繁琐的重复配置.The AnQi CMS solves this problem well through a clever default custom template naming mechanism, allowing content operation and frontend design to collaborate efficiently.
AnQiCMS Template Management Basics
The AnQiCMS template system is developed based on Go language, using.htmlfiles as templates, and stored uniformly in/templateThe directory. Its syntax is similar to Django template engine, through double curly braces{{变量}}to output data, through single curly braces and percentage signs{% 控制结构 %}To implement logic control.This design makes template development intuitive and easy to get started with.The system also supports various template types such as adaptive, code adaptation, and independent sites for PC and mobile, 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 according to specific naming rules.This means, for certain pages that require personalized display, we do not need to manually select a template in the background. As long as we create the template file in accordance with the agreed format, the system can automatically match and apply it.This design of 'preference over configuration' greatly simplifies the workflow, especially suitable for websites with large amounts of content and many customization requirements.
Specifically, the Anqi CMS supports the following important default custom template names:
- Document details 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 the user accesses this article with the ID of123的文章时,AnQiCMS will automatically load and usearticle/123.htmlas its detail page template. - Category list page:
Sometimes, we may want the list page of a specific category (such as "Latest News" or "Special Offers") to have a distinctive display style.AnQiCMS allows you to create a dedicated list template for specified category ID.
{模型table}/list-{分类id}.htmlFor example, if your product model table name isproductand you want ID to be5The product category displays different list styles, you can create filesproduct/list-5.html. When a user visits the product category ID of5, the system will automatically enable this custom template. - Single Page Detail PageFor independent single-page sections like 'About Us' and 'Contact Information', personalized design is equally important.AnQiCMS also provides a default template mechanism based on ID for single-page applications.
page/{单页面id}.htmlFor example, if the ID of your 'About Us' single page is7, you can create a filepage/7.html. AnQiCMS will prioritize and apply when rendering this single pagepage/7.html.
Flexible hierarchy and priority
AnQiCMS follows a clear priority rule in template selection, ensuring both automation and the highest level of customization:
- Background manual template specificationThis is the highest priority. If you specify a template file explicitly while editing documents, categories, or single pages in the background (for example, by filling in the 'Document Template' or 'Category Template' field)
special-download.html),then the system will always use this specified template, regardless of whether there is a template that matches the default naming rules. - Default ID naming template:Next is what is mentioned above, based on
{模型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. - Universal template:If the above two templates do not 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 look up{模型table}/list.html(such asarticle/list.html);For all single pages, it will look uppage/detail.html.
This hierarchical design allows website administrators to flexibly choose whether to use a general template, customize a template for a specific ID, or explicitly specify 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:
- Enhance efficiency:For scenarios with a large amount of content but only a few that require special design, there is no need to frequently enter the background to select templates. Just create a file is enough.
- Fine-tuned customization:Allow each key content or page of the website to be visually and functionally customized at the pixel level without interfering with each other.
- Simplify management:Template file naming follows a regular pattern, enabling front-end developers and content operators to better understand the purpose and relevance of the template, reducing maintenance costs.
- Optimizing user experienceEnglish: Provide a more fitting display method for content of different types or importance, indirectly enhancing user experience and conversion rates.
In summary, AnQiCMS combines intelligent 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 complex technical details.
Common Questions (FAQ)
Q1: If a category or document exists with 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, templates manually specified in the backend have 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 unconditionally load and apply this manually specified template without looking for or using any templates that match the default naming rules.This design ensures that operators have absolute control over specific pages.
Q2: The default custom template naming rule is{模型table}what does it mean? Where can I find this name?
A2: {模型table}是指内容模型在数据库中的表名,也是该内容模型在模板系统中的标识符。AnQiCMS内置了“文章模型”和“产品模型”,它们的模型表名通常是articleandproduct(The specific name can be viewed or customized in the backend under "Content Management" - "Content Model").If you create other custom content models, the table name of the model also needs to follow this rule.news.
Q3: Can I set a default template for all articles or all categories in AnQiCMS, in addition to naming templates by ID?
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.html(Used for all document detail pages) and{模型table}/list.html(Used for all category list pages). For example,article/detail.htmlwill be used as the universal detail page template for all articles,product/list.htmlThen it will serve as the universal list page template for all product categories. These universal templates have lower priority than manually specified templates in the background and the default templates named by ID.