In website operations, providing exclusive display methods for specific content can significantly enhance user experience and the effectiveness of content marketing.AnQiCMS (AnQiCMS) is well-versed in this field, providing flexible and diverse template customization functions, allowing you to easily create unique and personalized layouts for articles, categories, or single pages.
The AnQi CMS implements personalized template customization in two main ways: one is through following specifictemplate file naming conventions; the other is inEnglish management interface manually specifiedCustom template file.
I. Automatic recognition through template file naming conventions
The design of Anqi CMS takes into account the general needs of daily content management and presets some naming rules for template files.As long as your template file follows these rules, the system will automatically apply them to the corresponding articles, categories, or single pages, without any additional backend settings.
These naming conventions are mainly based on the content ID or model table name. For example:
For specific article detail page:You can name the template file as
{模型table}/{文档id}.html. Assuming you have an article model, the model table name might bearticle. If you want to set for ID of10的文章(such as an important thematic article)create a dedicated template, you can name the template filearticle/10.htmlAnd place it in the current topic template directory. When the user accesses the article with ID 10, the system will automatically load and use this template.For the list page of a specific category:You can name the template file as
{模型table}/list-{分类id}.htmlEnglish. If you want to design a unique article list page for the category with ID5for the category (such as the "Company News" category), you can name the template filearticle/list-5.html(assuming that the category belongs toarticleModel),the system will automatically apply this template to the list of articles in this category.For a specific single page:You can name the template file as
page/{单页面id}.html. If you have an ID of3The 'About Us' single page, you can create for itpage/3.htmltemplate files, the system will automatically apply it.
The advantage of this method is that once the template file is named correctly and placed properly, the system can automatically identify it, saving the steps of setting one by one in the background, especially suitable for batch or regular personalized needs.
二、Through the backend management manually specify the template file
In addition to the naming conventions automatically recognized, the Anqi CMS also provides the flexible option to manually specify templates for specific content in the background management interface.This is very useful for those who do not want to follow a fixed naming rule, or need to temporarily change the layout for some content.
1. Customize the template for a specific article
When you edit an article, you can do so in the "Add Document" or "Edit Document" interfaceOther ParametersFind in the foldable item"Document Template"Field. Here, you can enter the filename of the template you designed for this specific article, such asdownload.html.
This means that you can create a special one for an article containing download linksdownload.htmlTemplate, make it distinct from ordinary articles in layout, highlighting the download button or related instructions.Please make sure that this template file exists in the currently enabled theme template directory, otherwise the article will not be displayed normally.
2. Customize templates for specific categories
Under the 'Content Management' module and 'Document Category' settings, when you edit a category, you will seeOther Parametersparts of it'Category Template'Field. This field allows you to specify a custom template for the list page or detail page of the current category, for examplespecial-list.html.
It is worth noting that the category template also provides a“Is applied to subcategory”The option.If this option is selected, all subcategories under the current category will inherit the custom template you set here.This greatly simplifies the work of unifying layouts for a series of related categories.
In addition, there is another setting in the category"Document Template"field. The function of this field is, you can specify the category underall articlesAll are unified to use a certain custom template. For example, if you have a 'product display' category, you can specify the 'document template' in its category settings.product_detail.htmlThen all product articles under this category will use this template to display, without the need to set it separately for each article.
3. Custom template for a specific single page
In the "Page Resources" module under "Page Management", when editing a single page, you can find“Single Page Template”Field. Here, you can enter the template file name for this single-page design, for exampleabout-us.html.
Here, you can give "About UsSimilarly, make sure that the template file you filled out actually exists in the template directory of the current theme.
III. Basic Considerations for Template Design
No matter whether you choose automatic recognition or manual template specification, all custom template files should be stored in/templateIn the currently enabled theme folder under the directory. The template engine of AnQi CMS is similar to Django, using a concise and intuitive syntax:
- Variable output:Use double curly braces
{{ 变量名 }}to display data. - Logic control:using single curly braces and percent signs
{% 标签名 %}autoifautoforautoincludeautoextends) etc.
autoincludeTag to introduce page header, footer, sidebar, and other common code snippets to improve the maintainability and reusability of templates. At the same time,extendsThe label inherits a basic layout template, ensuring that custom templates can maintain individuality while also keeping in line with the overall style of the website.Please make sure to save your template file using UTF-8 encoding to avoid issues with Chinese garbled text.
Through the above two methods, the security CMS provides you with powerful template customization capabilities, whether it is fine-tuned to a single article or acts on the entire category, you can flexibly control it to achieve truly personalized website layout.
Common Questions (FAQ)
1. I set a custom template for the article, but the page still displays the default style. Why is that?
2. In the category settings, what is the difference between 'category template' and 'document template'? Will they affect each other?
3. If I create a template that conforms to the naming convention (for examplepage/3.html) and also manually specify a custom template (for exampleabout-us.html), which one will take effect?In most cases, the custom template manually specified by the background takes precedence over the template recognized automatically by file naming conventions. When the system