In AnQiCMS, in order to achieve personalized display of website pages or categories, we do not always have to write complex logic from scratch, the system provides a very flexible and intuitive template file naming convention.These conventions allow us to create template files with specific names, enabling the system to automatically recognize and apply them, thereby customizing the display of different content types.
First, understanding the basic structure of the template file is crucial. All template files are stored in/templatethe directory and are used uniformly..htmlAs a file suffix. For example, a template named "default" will be located at/template/default/Below. It is recommended to place the static resources such as styles, JavaScript scripts, and images used in the template separately to maintain order and efficiency./public/static/Directory, to keep it organized and efficient.
The strength of AnQiCMS lies in its support for a variety ofDefault convention for custom template names. When the system is rendering the page, it will intelligently search for the existence of template files that match these specific naming rules.If found, they will be used preferentially without any additional configuration on our part.
Specifically, these naming conventions include:
- Custom template for document detail page: If you want to provide a unique display effect for a specific document, you can name the template file according to
{模型table}/{文档ID}.htmlthe format. For example, if your website has aarticle(Article) model, where the ID is100the article requires a special layout, then you can create a namedarticle/100.htmltemplate file. When the user accesses this article with ID 100, the system will automatically load this custom template. The naming convention also applies to product models, such asproduct/201.html. - Custom template on the category list page: To make the article or product list of a specific category have a unique style, you can follow
{模型table}/list-{分类ID}.htmlnaming format. Assuming yourproduct(Product) There is an ID of5category, you can createproduct/list-5.htmlCustomize the list display of this category. This way, when users browse the product category page with ID 5, they will see this exclusive list layout. - Custom template for the single-page detail page.: For common single-page templates like 'About Us' and 'Contact Us', customization is also possible. The naming format is
page/{单页面ID}.html. For example, the ID is1The single page (usually might be "About Us"), you can createpage/1.htmlto define its display style.
In addition to these naming conventions automatically recognized by the system, AnQiCMS also grants website administrators more advancedcustom template specification capabilitiesThis means that even if it does not follow the above naming conventions, website administrators can still manually assign a completely custom template file for specific documents, categories, or even individual pages according to the needs of content operation.
For example, you may want the "About Us" page to have a special designabout-us.htmltemplate instead of the default onepage/{单页面ID}.html. All you need to do is in/template/你的模板目录/page/Createabout-us.htmlThen edit the 'About Us' single page in the background and directly fill in the 'Single Page Template' fieldabout-us.html. AnQiCMS will use the template you specified in the background first when rendering this single page.The same method also applies to the custom template settings for documents and categories.This approach provides great flexibility, able to handle various personalized display needs, such as customizing exclusive templates for specific marketing activity pages, download pages, or partner introduction pages.
On the organization of template files, AnQiCMS supports two modes: "folder organization mode" and "flattened file organization mode". Regardless of which one is chosen, the above naming conventions are universal. In addition, to better adapt to mobile device access, AnQiCMS allows us to create in the template directorymobile/Subdirectory. In thismobile/Under the directory, you can follow the same naming conventions as the PC end to design independent template files for mobile devices, thereby providing differentiated high-quality user experiences on both PC and mobile devices.
By these flexible naming conventions and backend specification mechanisms, AnQiCMS greatly simplifies the complexity of template customization.It enables website operators to efficiently implement highly customized displays for different content types, functional modules, or specific pages, thus attracting users better, optimizing the user experience, and serving specific business goals.
Frequently Asked Questions (FAQ)
Ask: In AnQiCMS, should I prioritize using template naming conventions or manually specifying templates in the background?Answer: It depends on your customization needs. If you just want to provide a dedicated template for a document, category, or single page with a fixed ID and do not want to frequently operate in the background, then follow the naming conventions (such as
article/100.html)Will be more efficient, the system will automatically recognize. But if your customization needs are more flexible, such as some documents in a category needing one template, and others another, or if you want to specify a general template that is different from the default name for a particular page (such aspromo-page.htmlThen specifying a template file manually in the background will provide greater control. Typically, manually specified in the background has a higher priority than the default naming convention.Ask: If I created a naming convention template (for example
article/100.html), but then manually edited the article in the background to specify another template (for examplespecial-article.htmlWhich template will take effect in the end?Answer: In this case, the template manually specified by the background willspecial-article.htmloverride the naming convention templatearticle/100.htmlThe system will prioritize handling the template file path you explicitly configure in the background content editing interface.The naming convention is more of a convenient default mechanism, while the backend configuration provides finer-grained control and priority.Ask: Does AnQiCMS support customizing independent templates for mobile pages? How to implement it?Yes, AnQiCMS fully supports customizing independent templates for mobile pages. You just need to create a subdirectory named
mobile/in your current template directory, and thenmobile/Directory naming conventions are the same as on the PC (for examplearticle/100.htmlorpage/1.htmlCreate the corresponding mobile template file. When the website runs in "code adaptation" or "PC+mobile independent site" mode, the system will automatically load according to the user's devicemobile/The corresponding template under the directory.