AnQiCMS provides high flexibility in the creation and management of website templates, allowing users to easily achieve differentiated display of different pages, thereby meeting diverse content operation needs.This is due to its concise and efficient architecture and support for a variety of template patterns.

Understanding the template mechanism of AnQiCMS

The core of AnQiCMS templates lies in its user-friendly Django template engine syntax, which allows even users without a strong development background to customize templates relatively easily. All template files are stored in a unified location./templateIn the directory, each independent template will have its own dedicated folder. In this folder,config.jsonFile plays a crucial role, defining the name, version, author, and most importantly, the template type of the template.

The system supports multiple template types, includingAdaptive template/Code adaptation templateandPC+Phone independent template.This means you can choose a template to fit all devices, or design two completely independent templates for PC and mobile, or even bind a separate domain for mobile.mobilesubdirectory, and place the mobile end related template files in it. The system can then automatically identify and adapt.

Create and manage custom website templates

To create a new website template, first you need to/templateCreate a new folder under the directory, as your new template directory. Then, create aconfig.jsonFile, fill in the basic information of the template, such as template name, package name (recommended to be consistent with the folder name, for internal system identification), version number, etc.template_typeField (0 for auto, 1 for code adaptation, 2 for PC+mobile independent) andstatusField (0 for disabled, 1 for in use) is the key to controlling template behavior. The system defaults to only one set of templates.statusValue 1 indicates that it is in use.

AnQiCMS provides conventions for template file naming, which greatly simplifies the template creation process. For example, the homepage is usually namedindex.html, while the homepages of different content models (such as article list pages, product list pages) can be named{模型table}/index.html. Similarly, the article detail page can be named{模型table}/detail.html, the category list page is{模型table}/list.html, the single page detail page ispage/detail.htmlStatic resources (such as CSS, JavaScript files, images, etc.) are recommended to be stored in/public/static/directory to maintain a good file organization structure.

The enable and switch of the template is done in the AnQiCMS background, where you can conveniently select, enable or disable different templates from the template management interface in the background without manual modificationconfig.jsonfile.

Implement differentiation for different pages

AnQiCMS provides multi-level customization capabilities in the implementation of page differentiation:

  1. Global general page display:Like the website homepage (index.html)、search results page(search/index.html)and various error pages(errors/404.html,errors/500.html)and so on, can all be managed and displayed uniformly by predefined template names.

  2. Based on content model display:AnQiCMS's 'Flexible Content Model' is the cornerstone for differentiated display.You can create different content models based on your business needs (such as "articlesspecific categories/A specific documentorA specific single pageSpecify the independent template it uses. For example, a single page like "About Us", you can set its template topage/about.html,to have a completely unique layout and content presentation. An article on a special download page can specify its document template asdownload.html.

  3. Using template tags and logic control:Even in the same template file, it is also possible to use the rich template tags and logical controls provided by AnQiCMS (such as{% if ... %}condition judgment and{% for ... %}Loop traversal) to implement dynamic content display and layout differences. For example, usingarchiveDetailtags to obtain the detailed information of the current article, or throughcategoryDetailto get the category attributes. Combined withifThe display style and structure of the content can be determined according to whether the article has a thumbnail, whether it contains specific tags, and other conditions.

  4. Differentiation between multiple sites and multiple languages:If your business needs to manage multiple brands or sub-sites, AnQiCMS's 'Multi-site Management' feature allows you to select a separate set of templates for each site, even deploying it into a completely different website form.Coordinating with “Multilingual Support”, you can also provide customized templates for different language versions of the website to ensure that content is presented in various language environments.

Template Management and Maintenance

In order to improve the development efficiency and maintainability of templates, AnQiCMS templates support code reuse mechanisms. For example, using{% extends 'base.html' %}Tag implementation template inheritance, abstracting the common structure of the website (such as header, footer) tobase.htmlIn, the child template only needs to rewrite{% block ... %}Defined specific areas. At the same time, utilizing{% include "partial/header.html" %}Introduce reusable code snippets, or through{% macro ... %}Define macro functions with parameters, which can effectively reduce redundant code.

AnQiCMS also includes a backend editing template feature, making it convenient for you to make lightweight template modifications and debugging. For multilingual websites, the system also supports multilingual template definitions, which can be accessed through{% tr "yourLocation" %}This label implements the translation and switching of interface text.

In summary, AnQiCMS provides a powerful and flexible template creation and management solution, from global template selection to specific page customization, to the dynamic display of content and multilingual adaptation, all of which allow you to efficiently create a website that conforms to the brand image and user experience.


Common Questions (FAQ)

  1. How to change the template currently in use on the website?You can find the 'Website Template Management' page under the 'Template Design' menu by logging into the AnQiCMS backend.Here, you can see all uploaded templates. Select the template you want to enable and click the "Enable" button to complete the switch.Please note that after switching the template, the style and layout of the website's front page will change immediately.

  2. Can I use completely different template layouts for the PC and mobile versions?Yes. When you create the template, you can do so in the root directory of the template.config.jsonthe file containstemplate_typeSet to 2 (PC+phone independent mode). Next, create a file namedmobileThe subdirectory, and place the template files designed for mobile phones in it.The system will automatically load the corresponding template based on the type of device accessed.You can even bind a separate domain for the mobile end in the "Background Settings".

  3. I have a special "Contact Us" page that needs a layout completely different from other single pages, can AnQiCMS achieve this?Of course, you can.When creating or editing this "Contact Us" page, there is an option for a "Single Page Template" in the backend editing interface.contact.html(Make sure that this file exists in your current template directory'spage/folder, iftemplate/your_template/page/contact.html)。Thus, this particular single-page will display the unique template you specify, achieving a completely personalized layout.