In AnQiCMS, customizing the display templates for articles, products, and single pages is a very flexible and powerful feature that allows you to create dedicated display styles for different types of content based on the unique needs of your website.By carefully designed templates, not only can it enhance the user experience, but also better highlight the key points of the content, realizing the unity of brand style.
AnQiCMS uses a template engine syntax similar to Django, which means if you are familiar with this concise and intuitive syntax, you can get started quickly. Template files are usually written in.htmlwith suffix, and stored uniformly in/templateUnder the directory. Each template package has its own directory, internally throughconfig.jsonFiles define template information and support adaptive, code adaptation, and independent PC + mobile sites and other modes, ensuring that your website can perfectly present on different devices.
Customize the article display template flexibly
In AnQiCMS, the article display template can be customized in multiple layers.
First, each content model (such as the "article" model) has a default detail page template, usually named{模型table}/detail.htmlfor examplearchive/detail.htmlIf you have not specified a template for a specific article, the system will automatically use this default template.
When you want a specific article to have a unique display style, you can set it in the "Content Management" "Publish Document" or "Edit Document" interface in the background.In the "Other Parametersmy-special-article.htmlIt should be noted that this custom template file must actually exist in the template package you are using, otherwise the system will not be able to find and load the page.
Moreover, AnQiCMS also provides a convenient default naming convention: you can create a template file named{模型table}/{文档id}.htmlsuch asarchive/10.html), it will be automatically applied to the article with ID 10, without any additional configuration in the background. This method is especially suitable for scenarios where it is necessary to design a few key articles independently.
In these custom article templates, you can use{% archiveDetail %}tags to retrieve the details of the current article, such as{{archive.Title}}Display the article title,{{archive.Content|safe}}Display the article content(|safeThe filter is used to ensure that HTML content is rendered correctly, avoiding escaping). If the article model defines additional custom fields, they will also be automatically included in the template.{{archive.您的自定义字段名}}Call in the form.
Custom product display template
The product is also considered a content model in AnQiCMS, and its template customization process is very similar to articles. Usually, the default template of the product detail page is also{模型table}/detail.htmlfor exampleproduct/detail.html)
If you want a specific product page to have a unique layout or information display, you can also specify a custom template file in the "Other Parameters" field under the "Document Template" field when editing products in the background, for example,product-showcase.html.
When customizing the product template, you will find{% archiveDetail %}The tag is still the core of obtaining product data. It can help you retrieve the product name, image, description, and even various parameters customized through the content model, such as{{archive.Price}}or{{archive.Materials}}(Assuming you have defined the "price" and "material" fields). Combine{% archiveParams %}Label, you can also loop through all custom product parameters to flexibly build product specification lists.
Custom single page display template
Single-page pages (such as "About Us", "Contact Us") also provide independent template customization capabilities in AnQiCMS. By default, the detail page template of single-page pages ispage/detail.html.
If you want to design a unique style for a single page, you can edit the single page in the "Page Resources" "Page Managementabout-us.html.
Similar to the article, AnQiCMS also supports automatic application of templates through default naming conventions: if a file namedpage/{单页面id}.htmlexists, it will be automatically applied to the single page with the corresponding ID.
In a single-page template, use{% pageDetail %}tags to easily obtain the page title, content, thumbnail information, etc. For example,{{page.Title}}to get the title of the single-page,{{page.Content|safe}}to get the main content of the single-page.
Category page template customization
In addition to the details page of articles, products, and single pages, AnQiCMS also allows you to deeply customize the display template of category pages, which is crucial for displaying list content.
Each content model has a default list page template, usually{模型table}/list.htmlfor examplearchive/list.htmlorproduct/list.html)
If you wish to display the article list under a specific category (such as "News Centernews-list-template.html.
Further, AnQiCMS allows you to create a named category for specific categories{模型table}/list-{分类id}.htmlsuch asarchive/list-5.htmlThe file will be automatically applied to the article category with ID 5."),
It is worth mentioning that there is also a "document template" field and the option of "whether to apply to subcategories" in the category settings.This means that you can not only customize the list page template for the category itself, but also specify a detailed page template for all articles/products under the category and its subcategories, which greatly simplifies the management of multi-level content and style uniformity.
You can use it in the category template,{% categoryDetail %}Label to obtain the details of the current category, such as{{category.Title}}/{{category.Description}}. To display the list of articles or products under the category, you need to use{% archiveList %}Label, and throughcategoryIdparameter to specify which category's content to list, combined withtype="page"and{% pagination %}The label can easily implement pagination.
The organization and filling of the template file.
The template file organization of AnQiCMS is very flexible, you can choose the "folder organization mode" or the "flattened file organization mode". For example, in folder mode, you can place the article detail page inarchive/detail.htmland the single page detail page is placed inpage/detail.html.
The core of any organizational mode chosen is to use various template tags provided by AnQiCMS to fill in the content. In addition to the aforementionedarchiveDetail/pageDetail/categoryDetailAnd `archiveList`