In website operation, we often need to present unique design or functional layout for specific content (whether it is detailed documents, entire category pages, or independent single pages).AnQi CMS provides a flexible mechanism that allows users to easily specify independent display templates for this content, thereby achieving highly personalized website display effects.
To understand how to set up an independent template, we first need to have a basic understanding of the template mechanism of Anqi CMS. In Anqi CMS, the template files of the website are usually stored in/templateUnder the directory, each topic has its own independent folder. These template files are used to define the structure, style, and content display of web pages in HTML.The system will automatically match the default template based on URL path, content type, and other information, for example, the article detail page may usearticle/detail.html, for the category list pagearticle/list.htmlWhen the default template fails to meet specific needs, an independent template comes into play.
Set an independent display template for a specific document.
If you have an important announcement, a special product introduction, or an article that requires a unique layout style, you can specify a unique template for it.
When you enter the AnQi CMS backend management interface, click on 'Content Management' under 'Publish Document' or edit an existing document, you will see a form with various settings.Scroll down to find the collapsible area called "Other Parameters".Expand it, and you will find a text box named "Document Template".Here, you can directly enter the custom template file name you want to use for this document.
For example, if you have designed a special template nameddownload.htmlin the 'Document template' input box.download.htmlAs soon as it is done. When the system accesses this document, it will call the one you specifieddownload.htmlto render the page content, instead of using the default document detail template of the model.
Set an independent display template for a specific category
The category page is usually used to display a series of related content, such as a product line or service project.If you want the list page of a category to have a unique layout, for example, a special topic page or a product guide page, you can also set a template separately.
Navigate to the "Content Management" under "Document Category" in the background, select the category you need to edit.In the category editing page, in the "Other Parameters" area, you will find a "Category Template" field.Here, you can enter the template filename designed for this category, such asproduct-showcase.html.
It is worth mentioning that the category template settings also have an option for 'Apply to subcategories'.Tick this option, all subcategories under this category (if they do not have an independent template themselves) will follow this custom template. This is very helpful for maintaining a unified style of content display for specific business lines.
Set an independent display template for a specific single page
A single page, such as 'About Us', 'Contact Us', or 'Terms of Service', etc., often carries key information of the website, and its design may need to be completely different from blog articles or product list pages.
Log in to the background, go to 'Page Resources' under 'Page Management', and select or create your single page.In the form of editing a single page, you will also find a setting item for 'Single Page Template'.Enter the name of your custom template file, for exampleabout-us-v2.html. The system will use the file you specified to display content when accessing this single page. This provides great flexibility for creating highly customized landing pages or company profile pages.
Key points to note
When using this feature, there are several important points to keep in mind:
- The template file must exist:No matter whether you are setting a custom template for documents, categories, or single pages, the most important thing is that the template file you fill in must truly exist in the theme folder you are currently using.If the file does not exist, the page will not display normally, and error messages may appear.
- File location:Generally, these custom template files are placed in your theme directory (for example,
/template/default/The root directory, or the subdirectory corresponding to the content type under the topic (for examplearticle//product//page/). The system will try to find the file you specified at a reasonable location. - Naming suggestion:Name your custom template file clearly and meaningfully, for example
special-promo.htmlinstead oftemp1.htmlThis helps you better manage and maintain the website. - Priority:The independently set template in the background takes precedence over the system default template rules. This means that even if there is a default template
article/detail.htmlif you specify a template for a documentmy-unique-article.htmlSo the system will use the latter. - Thorough testing:After each setting or change of the custom template, be sure to visit the corresponding page on the front end to ensure that the template is loaded correctly and the content is displayed correctly.
By following these steps and precautions, you can fully utilize the template customization capabilities of Anqi CMS to create unique user experiences for different parts of the website.
Frequently Asked Questions (FAQ)
Q1: What will happen if I set a custom template but forget to upload the template file to the server?A1: If the custom template file you specified does not exist on the server, when accessing the corresponding page, the AnQiCMS system will not be able to find the template file to render, which will usually display an error page or a default system error prompt, causing the page content to be displayed normally.Therefore, make sure to set the custom template name in the background after which, upload the corresponding template file correctly to the template directory of the currently enabled theme.
Q2: Can I set a custom template for a category and also set another template for a specific document under that category? Which one will take effect?A2: It's okay. In this case, the custom template set at the document level takes precedence over the template set at the category level.That is to say, if Category A uses template A, and document 1 under Category A uses template B, then document 1 will use template B when accessed, and other documents under Category A (without a separately set template) will use template A when accessed.
Q3: Where should my custom template file be placed in the theme directory?A3: Generally, you can place the custom template files directly in the root directory of the theme you are currently using (for example/template/你的主题名/)。AnQiCMS looks for templates by intelligently matching content types and template names.But for better organization and management, you can also place it in the corresponding model subdirectory under the theme, for example, the template related to articles can be placed inarticle/folder, and the templates related to single pages are placed inpage/In the folder. As long as the name you fill in the "Document Template", "Category Template", or "Single Page Template" fields in the background matches the file path (if it is not in the root directory of the theme, then it needs to include the subdirectory name, such aspage/about-us.html)Match it.