AnQiCMS as an enterprise-level content management system based on the Go language, its powerful modular design is one of its core advantages.This design philosophy is not only reflected in the system architecture, but also profoundly affects the flexibility of template secondary development and personalized display adjustment, allowing website operators to easily create unique and highly customized content platforms.
The foundation of AnQiCMS modular design
AnQiCMS can achieve efficient and flexible template customization due to its underlying modular architecture.Developed based on the Go language, the system itself has the characteristics of high concurrency and high performance, and the modular development method ensures that each functional point can be independently upgraded and expanded.This means that when we develop or adjust templates, we don't have to worry about a chain reaction, as each functional module can be regarded as an independent building block, providing great convenience for secondary development.
In addition, AnQiCMS uses a syntax similar to the Django template engine, which is very easy for users familiar with web development to get started. It starts with.htmlAs a template file suffix, and store it uniformly in/templatethe directory. In the template, use double curly braces{{变量}}to define variables, use single curly braces and percent signs{% 标签 %}to define logical control tags (such as conditional judgmentsifand loopsfor), and tags must be paired, such as{% if ... %}{% endif %}. Static resources (such as CSS, JS scripts, images) are stored in/public/static/directory, a clear structure helps to manage and maintain efficiently.
Exquisite template structure and flexible file naming
AnQiCMS template organization provides great freedom.It supports two file organization modes: folder organization mode and flattened file organization mode.
- Public code reuse:Like the header (
bash.html), footer, and other parts that may be inherited by each page, it is recommended to place them in the public area, through{% include "partial/header.html" %}By means of reference. - Code snippetification:Sidebar, breadcrumb, and other reusable code snippets can be stored in
partial/directory for unified management. - Page-level customization:Home, Model home, Document detail page, List page, Single page, Search page, Error page, etc. have their corresponding default naming conventions. For example, the document detail page can be
{模型table}/detail.html. - The customization is ultimate:AnQiCMS supports customizing exclusive templates for specific document IDs, category IDs, even single page IDs. For example, you can create a template for a document with ID 10.
{模型table}/10.htmlof the template file, or create one for the 'About Us' single pagepage/about.htmlThe template. When setting up in the background, just specify the corresponding template name, and the system will automatically apply it to achieve a high degree of personalized display adjustment. - Adapt for mobile:To meet the needs of multi-device access, the template supports adaptive, code adaptation, and PC + mobile independent site mode. When using code adaptation or PC + mobile independent site mode, you can
mobile/Create a mobile-specific template consistent with the PC template structure under the directory, ensuring that the content has a** display effect on different devices.
Rich template tags: a bridge between data and logic
AnQiCMS comes with 38 commonly used template tags, which are powerful tools for connecting backend data with frontend display. These tags can be roughly divided into several categories:
- System-level information:
systemTag used to get the website name, LOGO, filing number and other global configurations;contactTag used to retrieve contact information;tdkTags are responsible for the page's SEO meta information (Title, Keywords, Description). - Content organization:
navListUsed to build website navigation;breadcrumbIt can automatically generate the breadcrumb navigation for the current page. - Data call:
- Category and single page:
categoryListandcategoryDetailUsed to get the category list and details;pageListandpageDetailIt is used for the list and details of the single page. - Document Core:
archiveListA powerful tool to obtain lists of articles, products, and other documents, supporting multiple conditions for filtering by category, model, recommended attributes, sorting methods, and even pagination.archiveDetailIt is used to obtain detailed information about a single document, including content, images, custom fields, etc. - Linked and navigated:
prevArchiveandnextArchiveUsed to quickly generate links to the previous/next article;archiveListIntype="related"You can access related documents in this mode. - Dynamic data:
tagListandtagDataListUsed to process tags and their associated documents;commentListManage comments;guestbookIt is used to generate a message form.
- Category and single page:
- Logical Control:
if else endifandfor empty endforIt provides basic conditional judgment and loop functions, which are indispensable for building dynamic templates. - Data Processing:
stampToDateCan format timestamps into readable dates;withTags can be used to temporarily define variables in templates. - Filters (Filters):This is a powerful tool for personalized display adjustments. For example,
safeUsed to output HTML content without escaping;truncatecharsortruncatewordsCan truncate long text and add an ellipsis;thumbUsed to get image thumbnails;urlizeAutomatically convert text URLs into clickable links. These filters allow for fine-grained processing and display of data.
Practical path for secondary development and personalized adjustment
Utilizing the modular design of AnQiCMS for secondary development and personalized display adjustment, usually following the following path:
- Custom content model and fields:In the background "Content Model", you can create or modify models according to business needs and add custom fields (such as "Article Author", "Product Price", "Property Area", etc.). These custom fields can be accessed through the front-end template.
archiveDetailorarchiveParamsEasily call tags to achieve personalized display of specific business data. - Customized template file:For specific categories, documents, or single pages, in the template directory (such as
template/{your_template_name}/Create a HTML file that conforms to the naming conventions. For example, you can createarticle/list-12.htmlCustomize the article category list page with ID 12, orproduct/detail.htmlTo unify the product detail page style. In the background management interface, you can specify the custom template to be used on the category, document, or single page editing page. - Make good use of template tags and filters:In a customized HTML template, combine the above rich tags and filters to call and format data. For example, using
{% categoryDetail with name="Logo" %}To get the Banner image of the category, use{{ item.Content|safe }}Display rich text content safely, or use{{ stampToDate(item.CreatedTime, "2006-01-02") }}To format the publish time. - Modular reference and inheritance:To enhance the reusability and maintainability of template code, make good use of
includeThe tag introduces common modules such as headers, footers, or sidebars to each page. For pages with similar structures but different content, you can useextendsTagging to implement template inheritance, first define a basic skeleton (such asbase.html), and then in the child template throughblocktag overlay or expand specific areas. AndmacroIt allows the definition of reusable code snippets, like passing parameters in a function, which further improves the encapsulation of code. - SEO and multilingual optimization:By
tdkEnsure that each page has a reasonable title, keywords, and description, and combine it with pseudo-static rules (configured in the background "Function Management"), to generate search engine-friendly URL structures.For a multilingual website, you can use the "multi-language support" feature of the backend and the corresponding logic in the templates to switch and display different language content.
The modular design and complete template tag system of AnQiCMS provide website operators with a powerful toolkit, making template secondary development and personalized display adjustment no longer an insurmountable technical barrier.By flexibly using these features, everyone can create a content display platform that meets business needs and has both visual appeal.
Frequently Asked Questions (FAQ)
Q1: How can I use a completely different template for a specific article or category?A: You can specify a custom template filename in the "Other Parameters" or "Category Template" field when editing articles or categories in the background. For example, if you want to use a unique template for an article with ID 10, you can create a file named in the template directory.
{模型表名}/detail-10.htmlThe file (for example,article/detail-10.html), then set "Document Template" in the article editing interface,detail-10.htmland it will be. For categories, it is similar, create{模型表名}/list-{分类ID}.htmlFile, and specify it on the category editing page.Q2: How can I ensure that my template changes display well on different devices (PC, mobile)?A: AnQiCMS supports various template modes to adapt to different devices.
- Adaptive template:The default mode, your template needs to use responsive design (CSS media queries, etc.) to automatically adapt to screen size.
- Code adaptation / PC + mobile independent site:If you select these two modes, you can
template/{你的模板名}/mobile/Create a mobile exclusive template file with the same structure as the PC template under the directory. The system will automatically load the corresponding template based on the user's device, realizing differentiated display on PC and mobile endpoints.
Q3: If I need to display some custom data that is not provided by the default tags of AnQiCMS, how should I handle it?A: AnQiCMS's "Content Model" feature allows you to add an arbitrary number of custom fields for content types such as articles, products, etc. After defining these fields in the background, they will be part of the document or category object and can be used in the frontend template.
archiveDetailorcategoryDetailtags, throughname="你的自定义字段名"The way to call directly. If the custom field returns complex data types (such as image groups), you may need to combineforLoop to traverse and display.