In website operation, we will always encounter some unique content, which may represent a special promotional activity, an important corporate report, or a page that needs to be presented specially.This content often does not meet the unified default style of the website, and needs its own 'face' to attract users and highlight the key points.AnQiCMS (AnQiCMS) understands this need and therefore provides a very flexible template customization feature, allowing us to easily set independent templates for specific articles, categories, or single pages, thus achieving customized content display.

Why do we need independent templates?

Imagine that most of the content on your website is conventional articles, and a simple template is enough to display them.But suddenly, you need to publish an annual report, which may contain a large number of charts, videos, and require a wider, more interactive layout; or you want to create a dedicated introduction page for a product series, with a completely different layout, button style, and image display from the ordinary product detail page.For example, single-page contents like "About Us" or "Contact Us" have fixed content and structure, often requiring a unique brand display style.

In this case, if only the default template can be used, the website content will appear monotonous and will not highlight the value of specific information.The independent template function of AnQi CMS is exactly designed to solve this pain point, so that every piece of content can be presented in the most suitable way to the visitors.

The basic storage and naming rules of template files

In the Anqi CMS, all template files are stored in the root directory of the website/templateFolder. Each template has its own subdirectory, for exampledefaultThe template is located/template/default. The custom template file you create is usually also.htmlsuffix.

The template engine of Anqi CMS supports Django template engine syntax and is very easy to use. It also provides some default naming conventions based on content ID or category ID, which is a convenient way to customize.

  • Document (article/product) details page:You can create a name for{模型table}/{文档id}.htmltemplate, for examplearticle/123.html, the system will automatically recognize and apply to the article with ID 123.
  • Category list page:can create{模型table}/list-{分类id}.htmltemplate, for example:product/list-45.htmlThe product category list page with ID 45 will automatically use this template.
  • Single Page Details Page:Similarly,page/{单页面id}.htmlSuch a naming, such aspage/7.htmlCan automatically customize the single page with ID 7.

In addition to these automatically recognized naming conventions, you can also customize more descriptive template filenames as needed, such asarticle/special_event.htmlorpage/about_us.htmlThe next step is to see how to associate these custom templates with your content in the background.

Apply independent templates to specific content in the background.

The backend interface design of Anqi CMS is intuitive, and it is very convenient to associate custom templates with content.You only need to find the corresponding "template" setting item when editing the relevant article, category, or single page and enter the filename of the template you have prepared.

1. Set an independent template for a specific article (or product)

When you need a specific article (or a product detail page) to have a unique display style:

  • Firstly, create the corresponding template file in your template directory, for examplearticle/annual_report.html.
  • Then, log in to the Anqi CMS backend, go toContent managementSelect,Publish documentorEdit document.
  • Find the foldable area at the bottom of the editing pageOther parametersand expand it.
  • You will see a text box namedDocument template. Here, enter the name of your custom template file, for exampleannual_report.html. Please note that you only need to fill in the filename, not include/article/Such model directory prefix, the system will automatically recognize.
  • After saving, the detail page of this document will use the one you specified.annual_report.htmlThe template will be displayed.

2. Set an independent template for a specific category.

If you want all the contents under a certain category (including the category list page and the article detail page under the category) to have a unified custom style, you can set it at the category level:

  • Similarly, first create the custom template file, for example, for the list page,category/promo_list.htmlas well as the article detail page under this category,article/promo_detail.html.
  • Log in to the Anqi CMS backend, go to,Content managementSelect,Document Category.
  • Select the category to be customized, clickEdit.
  • On the editing page,Other parametersyou will see two important template settings:)
    • Category Template:This is used to customize the list page of the current category. For example, you can fill inpromo_list.html.
    • Document template:This is used to customize the detail page of all articles (or products) under the current category. For example, you can fill inpromo_detail.html.
  • There is also anotherWhether to apply to subcategoriesThe option. If you want this setting to also apply to all subcategories of the current category, remember to check it.
  • After saving changes, the content of this category and its subcategories (if checked) will be displayed according to your settings.

3. Set an independent template for a specific single page

For independent single pages such as "About Us" and "Service Introduction", the steps to customize templates are similar to articles, and they are very straightforward:

  • First, prepare your single-page template file, such aspage/contact_us.html.
  • Log in to the Anqi CMS backend, go to,Page ResourcesSelect,Page Management.
  • Select the single-page you want to customize, clickEdit.
  • Find the foldable area at the bottom of the editing pageSingle Page Templatethe input box.
  • Enter the custom name of your template file here, for examplecontact_us.html.
  • After saving, this single page will be displayed in the exclusive style you designed.

Content display in custom template

Once you have set up an independent template for specific content, you can fully utilize the powerful Django template engine syntax and built-in tags of AnQi CMS in these template files to build content. Whether it is the article detail page of{% archiveDetail %}Tag to get article content and custom fields, or category list page of{% archiveList %}Tag to loop display article list, or single page of{% pageDetail %}Tags, these can all help you flexibly display the required data and achieve truly customized content presentation. You can also combine conditional judgment{% if %}Loop iteration{% for %}English translation: As well as various filters, making the logic and display of the template more rich.

Through this method, the security CMS not only provides a robust and efficient content management foundation, but also endows us with the ability to add more vitality and uniqueness to the website content.Say goodbye to the same old, start with customizing your exclusive template!


Common Questions (FAQ)

English translation: What will happen to the website if the custom template file I specify for the article/categorization/single page does not exist?If the specified template file does not exist, the system will not be able to find the corresponding template to render the page, which usually leads to errors in page display or the page being inaccessible. Therefore, be sure to ensure that the corresponding template file exists before filling in the custom template name in the background..htmlFile has been created correctly and placed in the template directory.

What is the difference between 'Category Template' and 'Document Template' in the classification template?'Category Template' is used to define this categoryList pageThe display style, for example, the news list page you visityourdomain.com/category/newsThe news list page you see when you access.“Document template”is used to define the detail page of all articles (or products) under this categoryThe detail page of all articles (or products)The display style, for example, what you see after clicking on a news item in the news listyourdomain.com/article/news-item-1Page. Through these settings, you can control the display style of the category list and the specific content within the list separately.

3. What security CMS features can I use in a custom template to dynamically display content?You can fully utilize the powerful template tags and filters of the security CMS in custom templates. For example, using "{%