As an experienced CMS website operation personnel in the information security field, I fully understand that a clear and efficient template naming rule is crucial for the management of website content and user experience.The AutoCMS provides great flexibility in template design and also establishes a set of default naming conventions, which is very helpful for us to quickly build and iterate web pages.
In Anqi CMS, all template files are named with.htmlAs a suffix name, and placed in the root directory of the system./templatefolder. Each independent template set will have its own directory, and it needs to include aconfig.jsonFile defines the basic information of the template. The CSS, JavaScript, images, and other static resources that the template depends on are recommended to be managed centrally in/public/static/Catalog, to ensure clear structure and convenient maintenance.
AnQiCMS provides two main modes of organization for templates:Folder organization modeandFlat file organization modeThese two patterns are slightly different in naming, but both aim to provide consistent and easily understandable conventions.
For the content model home page, this is usually a overview page showing all documents under a certain content model.Folder organization modeThe default naming rule is{模型table}/index.html. For example, if the table name of your content model isarticleThen the homepage template file of the article model isarticle/index.html. And inFlat file organization modeIn this case, the naming convention is{模型table}_index.html, which isarticle_index.html. In this way, the system can clearly identify and load the homepage of the corresponding model.
For the document detail page, this is the page that displays the complete content of a single document.Folder organization modeBy default, the general template file is{模型table}/detail.html。In addition, AnQiCMS also supports customizing templates for specific document IDs, following this naming convention{模型table}/detail-{文档ID}.html,or more generally{模型table}/{文档ID}.htmlThis means you can provide a completely unique display layout for a special document.Flat file organization modeThe default template file name for the document detail page is{模型table}_detail.htmlAlthough there is no explicit ID-specific template listed in the flattened mode, it usually follows a concise_detail.htmlas a general detail page.
Finally, there is the document list page, which is used to display the document list under a certain category. InFolder organization modeBy default, the common template file is{模型table}/list.html。If you need to customize the list page for a specific category, the system will search for{模型table}/list-{文档分类ID}.html。For example, the list page of articles with category ID 10 may bearticle/list-10.html.Flat file organization mode中,文档列表页的默认模板文件名为{模型table}_list.htmlThis convention makes it easy to customize the display style of list pages for different models and categories.
Understand and follow these default naming rules, which can help us develop templates and manage content more efficiently.同时,安企CMS也提供了灵活的自定义机制,允许我们在后台为特定内容(如单页面)指定独特的模板文件路径,进一步满足个性化的需求。This design combines convention and flexibility, which is a manifestation of the strong support provided by AnQiCMS in content operation.
Common Questions (FAQ)
1. If I create an ID-specific template file for a specific document or category, and the file does not exist, how will the system handle it?
AnQiCMS will first try to locate a template file specific to the ID, if the file does not exist, the system will automatically revert to searching for more generic template files. For example, for the document detail page,{模型table}/detail-{文档ID}.htmlDoes not exist, the system will try using{模型table}/detail.html. For the document list page, if{模型table}/list-{文档分类ID}.htmlDoes not exist, the system will fallback to using{模型table}/list.htmlThis fallback mechanism ensures that the website can still display normally even if a specific template is not created for each content, thus avoiding page errors.
2.{模型table}/{文档ID}and{文档分类ID}What does the placeholder 'auto' specifically represent? How can I obtain this information?
{模型table}It refers to the table name of your content model in the AnQiCMS database, for examplearticle(文章模型)或 Englishproduct(Product Model)。You can view or set each model's 'Model Table Name' field in the 'Content Management' -> 'Content Model' section of the AnQiCMS backend.{文档ID}指的是您在 AnQiCMS 后台发布的具体文档的唯一标识符 ID,在文档列表和编辑页面都可以看到。{文档分类ID}This refers to the unique identifier ID of your document's category, which can be viewed on the document category management page.
This information can be directly obtained from the backend management interface.
3. Template files, in addition to.htmlsuffix, also need to pay attention to which encoding or storage requirements?
All template files are encoded in UTF-8 format.If using other encoding, it may cause the page to display garbled text and not display normally.Especially for Windows users, when editing template files, please make sure to save them in UTF-8 encoding./public/static/directory, should not be confused with template files to maintain the clarity and convenience of the project structure.