AnQiCMS provides high flexibility in creating and managing website templates, allowing users to easily achieve differentiated display of different pages, thereby meeting the diverse content operation needs.This is due to its simple and efficient architecture and support for a variety of template patterns.
Understanding the template mechanism of AnQiCMS
The core of AnQiCMS templates lies in the easy-to-use 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./templateUnder the directory, each independent template will have its own dedicated folder. In this folder,config.jsonFiles play a crucial role, defining the name, version, author, and most critical template type of the template.
The system supports various template types, includingAdaptive template/Code adaptation templateandPC+mobile independent templateThis means you can choose a template to fit all devices, or design two completely independent templates for the PC and mobile end, or even bind a separate domain for the mobile end.In cases where an independent mobile template is needed, simply create a folder namedmobilePlace the mobile-end related template files in the subdirectory, and the system can automatically recognize and adapt.
Create and manage custom website templates
Create a new website template, first you need to/templatecreate a new folder under the directory as your new template directory. Next, create a new folder in this new directory.config.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. among themtemplate_typeField (0 for adaptive, 1 for code adaptation, 2 for PC + mobile independent) andstatusThe field (0 for disabled, 1 for in use) is the key to controlling template behavior. The system defaults to only one set of templates.statusA value of 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.htmlAnd different content model home pages (such as article list pages, product list pages) can be named{模型table}/index.htmlSimilarly, the article detail page can be named{模型table}/detail.htmlCategory list page is named{模型table}/list.htmlSingle page detail page is namedpage/detail.html. Static resources (such as CSS, JavaScript files, images, etc.) are recommended to be stored in/public/static/directories to maintain a good file organization structure.
The template enable and switch is done in AnQiCMS backend, you can easily select, enable or disable different templates in the template management interface of the backend, no manual modification is requiredconfig.jsonfile.
Implement the differentiated display of different pages
AnQiCMS provides multi-level customization capabilities in implementing the differentiated display of pages:
Global general page display:Like the website homepage(
index.html)Search result page(search/index.html)and various error pages(errors/404.html,errors/500.html)and others, can all be managed and displayed uniformly through preset template names.Display based on content model:AnQiCMS's flexible content model is the cornerstone of differentiated display.You can create different content models according to business needs (such as "articles", "products", "news"), and design a set of independent template structures for each model.Further, you can target in the backgroundSpecific categories/specific documentorspecific pagespecify the independent template it uses. For example, a "About Us" page, you can set the template to be
page/about.htmlTo make it have a completely unique layout and content presentation. An article for a special download page can specify its document template asdownload.html.Using template tags and logic control:Even in the same template file, you can also use the rich template tags and logic controls provided by AnQiCMS (such as
{% if ... %}condition judgment and{% for ... %}Loop through) to achieve dynamic content display and layout differences. For example, usingarchiveDetailtags to obtain the details of the current article, or throughcategoryDetailto obtain the classification attributes. CombineifThe statement, you can decide the display style and structure of the content based on whether the article has a thumbnail, whether it contains specific tags, and other conditions.Differences in multi-site and multi-language:If your business needs to manage multiple brands or sub-sites, AnQiCMS's 'Multi-site Management' feature allows you to independently select a set of templates for each site, even deploying them as completely different website forms.With "multilingual support", you can also provide customized templates for different language versions of the website to ensure that the content is presented in different language environments.
Template management and maintenance
To enhance the development efficiency and maintainability of templates, AnQiCMS templates support code reuse mechanisms. For example, using{% extends 'base.html' %}Implementing template inheritance, abstracting the common structure of the website (such as header, footer) tobase.htmlwhere the child template only needs to rewrite{% block ... %}defining specific areas. At the same time, utilizing{% include "partial/header.html" %}Introduce reusable code snippets, or through{% macro ... %}Define macro functions with parameters that can effectively reduce redundant code.
AnQiCMS also has built-in backend editing template features, making it convenient for you to make lightweight template modifications and debugging. For multilingual websites, the system also supports multilingual template definitions, and it can be done through{% tr "yourLocation" %}This label implements the translation and switching of interface text.
In summary, AnQiCMS offers a powerful and flexible template creation and management solution, from global template selection to page customization, to dynamic content display and multilingual adaptation, all of which can enable you to efficiently build a website that meets the brand image and user experience.
Frequently Asked Questions (FAQ)
How to change the template currently in use on the website?You can log in to the AnQiCMS backend and find the 'Website Template Management' page under the 'Template Design' menu.Here, you can see all the 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 front page will change immediately.
Can I use a completely different template layout for the PC and mobile ends?Yes. When you create a template, you can do so in the root directory of the template.
config.jsonfile willtemplate_typeSet to 2 (PC + standalone mobile mode). Next, create a folder namedmobileThe subdirectory, and put the template files designed for mobile in it.The system will automatically load the corresponding template based on the type of device being accessed.You can even bind a separate domain for the mobile end in the "background settings".Do 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 the 'Contact Us' page, there is an option for 'Single Page Template' in the backend editing interface.You can enter the name of the template file you have designed specifically for this special page, for example
contact.html(Make sure the file exists in your current template directory'spage/folder, such astemplate/your_template/page/contact.html). This specific single page will be displayed using the unique template you specified, achieving a completely personalized layout.