In daily website operation, the flexibility of content display is often the key to whether the website can stand out and meet the diverse needs of users.AnQiCMS (AnQiCMS) understands this and provides powerful custom template features, allowing content to not only be managed efficiently, but also presented in a way that conforms to brand characteristics and user habits.

Unlock the ability to customize templates in AnQi CMS

AnQi CMS is an enterprise-level content management system that has always focused on the customization of content display in its design.It is not just a simple content publishing platform, but also a stage that gives operators a high degree of freedom to create.As early as the V2.0.0-alpha7 version, Anqi CMS added the functionality of custom category templates, article templates, product templates, and page templates, which greatly expanded the imagination space for content operations.

This means that you are no longer limited to a single default layout, but can tailor a unique display style for specific documents, categories, or even independent pages on the website.This ability allows every content unit to maximize its value, whether it is to highlight a star product or to create a unique reading experience for a specific news category, it becomes effortless.

When to use custom templates? Scenario analysis

Then, in which scenarios will you find the powerful role of custom templates?

  1. Special article or product detail page:Imagine, on your website, there is an in-depth technical article that needs more reading space and code highlighting; or there is a flagship product that requires a dedicated page with rich pictures and multi-angle display.At this time, you can create a separate template for this specific article or product, making it visually distinct from regular content and providing a more immersive experience.{模型table}/{文档id}.htmlor specify a template nameddownload.htmltemplate file.

  2. Specific category list page:The website's "News DynamicSet exclusive list templates for these different categories, allowing users to quickly find the information they need and improve browsing efficiency.{模型table}/list-{分类id}.htmlOr its subcategory applies a custom template, and even set template inheritance so that subcategories can follow the template style of the parent category.

  3. Personalized single page:page/about.htmlSuch a file, and specify it to the 'About Us' page in the background.

The implementation path of the custom template

The process of implementing a custom template in Anqi CMS is intuitive and logical.

Step 1: Prepare the template file

Firstly, all template files are stored in/templatethe folder of the selected theme under the directory, for example/template/default/. Within the theme folder, you can create corresponding template files according to the Anqicms conventions. For example, for a specific document under the document model, you can create{模型table}/{文档id}.htmlFormatted file; for category lists, it is{模型table}/list-{分类id}.html.

If you want to create a named custom template for the "About Us" single pageabout.htmlyou can do so intemplate/default/page/Create in the directoryabout.htmlfile.

The AnqiCMS adopts a syntax similar to the Django template engine, variables are enclosed in double curly braces{{变量}}Condition judgment and loop control are used{% if ... %}/{% for ... %}Labels. When creating a template, make sure the file encoding is UTF-8 to avoid garbled characters, and properly store styles, JavaScript, and image resources in/public/static/Directory.

Step two: Specify the template in the background

After the template file is ready, the next step is to apply it to specific content.

  • For a single document:When you edit or publish a document in "Content Managementdownload.htmlThe system will prioritize displaying this document using the specified template.
  • For document classification:On the "Content Management" "Document Categorycategory-news.html. Further, you can also choose whether to apply it to the subcategory, so that the settings of the template are automatically inherited to the lower-level categories, reducing the repetitive configuration work.
  • For a single page: When editing a single page in the "Page Resources" "Page Managementabout.htmlIt allows the single page to use the independent layout you designed.

Step 3: Collaboration between content and template.

Once a custom template is specified, you can fully utilize the various tags provided by Anqi CMS to dynamically display content. For example, in the custom template of the document detail page, you can use{% archiveDetail with name="Title" %}To get the document title, use{% archiveDetail with name="Content" %}To display the article content. For the category list page,{% archiveList archives with type="page" %}Combine{% pagination pages %}You can easily build a paged article list.

By flexibly using these tags, you can beautifully present the data entered in the background according to the layout and design logic of the custom template on the website front-end.

The advantages of considering the custom template again

Using a custom template is not just an improvement in aesthetics, but also the implementation of website operation strategy. It allows your website to:

  • Optimizing user experience: Provide the most suitable reading or interactive methods for different content types, reducing users' understanding costs and operational difficulties.
  • Strengthen brand image:Integrate the unique visual style and interaction logic into every page to enhance the brand's recognition and professionalism.
  • Improve SEO effectiveness:Precisely control the structure and information hierarchy of the page, which is conducive to search engine crawling and understanding of the content, combined with static rules and other measures to further improve the SEO performance of the website.
  • Achieve fine-grained operation:Quickly deploy customized content display for different marketing activities or user groups, and flexibly respond to market changes.

In summary, the custom template feature of Anqi CMS provides solid technical support and unlimited creative space for your website operation.Master and make good use of this feature, it will make your content more expressive and your website more competitive.


Frequently Asked Questions (FAQ)

Q1: Why is the page still displaying the default template style even though I set a custom template?

A1: This situation usually has several possible causes. First, please check if your custom template file is correctly placed in the current theme./templateThe directory and the filename must be exactly the same as the one specified in the background, including case and extension.Secondly, ensure that the template file content has no syntax errors, otherwise it may cause the page to fail to render.Finally, AnQi CMS usually has a caching mechanism, please try to clear the system cache in the background, then refresh the page to see the effect.In addition, if your pseudo-static rule configuration is incorrect, it may also affect the correct loading of custom templates. Please check if the pseudo-static settings match your URL structure.

Q2: How to call the specific field data under the current document or category in a custom template?

A2: The AnQi CMS provides rich template tags to help you call data. For document detail pages, you can use{% archiveDetail with name="字段名" %}to get any field of the current document, such as{% archiveDetail with name="Title" %}Get the title,{% archiveDetail with name="Content" %}Get the content. Similarly, on the category page or in the list template, you can use{% categoryDetail with name="字段名" %}to get the details of the current category, for example{% categoryDetail with name="Description" %}Get the category description. If you need to call a custom field, just set thenameparameter to the name of the custom field.

Q3: Can I use different list templates for different categories under the same model?For example, the 'news' category of the article model uses one list style, and the 'blog' category uses another?

A3: Absolutely.In the Anqi CMS backend, under "Content Management" -> "Document Category", edit the category you want to customize (such as the "News" category), and find the "Category Template" field in the "Other Parameters" section.list-news.html. Then, specify another template file at the same location for the "Blog" category, for examplelist-blog.html.This, the article list page under different categories will load the independent list template you designed, displaying different display styles.At the same time, you can also check the option 'Apply to subcategories', so that all subcategories under this category will follow this template without the need to set them individually.