How to customize the display layout and template file path for articles (or other content) in AnQiCMS?

Calendar 👁️ 71

In AnQiCMS, the display form of your website content has high flexibility.No matter whether it is an article, product details, or an independent page, you can tailor the display layout and template file path to them according to the brand image, content characteristics, or specific operational needs.This design concept of AnQiCMS aims to help users break free from the constraints of traditional CMS and have more freedom in controlling the visual presentation and user experience of the website.

Flexible template mechanism: the foundation of AnQiCMS

AnQiCMS uses a template engine syntax similar to Django, making the creation and management of template files intuitive and efficient. All template files are stored in the project's/templateIn the directory, while CSS, JavaScript, images, and other static resources have their own/public/static/directory for management. Understanding this basic structure is the first step in custom layout.

In the writing of template files, variables are defined using double curly braces{{变量}}and logical tags such as condition judgment, loop control, etc. use single curly braces and percent signs{% 标签 %}And these logical tags must have corresponding end tags. To ensure the normal display of the page, all template files should use UTF-8 encoding.

AnQiCMS also supports various website modes such as responsive, code adaptation, and independent PC and mobile site modes. If you choose code adaptation or PC + mobile mode, the system will allow you to/templateUnder the directorymobileIn the subdirectory, a separate template is designed for mobile devices.

Two modes of template file organization.

To adapt to different development habits, AnQiCMS provides two template file organization modes:

  1. Folder organization mode:In this mode, different types of content will have their own independent folders to store template files, for example:

    • Home:index/index.html
    • Article (or other model) detail page:{模型table}/detail.html
    • Article (or other model) list page:{模型table}/list.html
    • Single page detail page:page/detail.html
    • Public code (such as header, footer):bash.html
    • Code snippet (such as sidebar, breadcrumbs):partial/
  2. Flattened file organization mode:In this mode, all template files are directly stored in the template root directory, and the file naming is differentiated by underscores, for example:

    • Home:index.html
    • Article detail page:{模型table}_detail.html
    • Article list page:{模型table}_list.html
    • Single page detail page:page.html

No matter which mode you choose, the key is that the system will automatically match the template according to the preset naming rules.

Intelligent default template matching

The intelligence of AnQiCMS lies in its ability to automatically match some default-named template files based on the type and ID of the content. This means that if you follow specific naming conventions, even if you do not manually specify the template in the background, the system can automatically apply them:

  • Document (article, product, etc.) detail page:The system will try to find and apply a path format of:{模型table}/{文档id}.htmlThe template file. For example, if an article with ID 10 is under the article model, the system may look forarticle/10.html.
  • Document List Page:For a document list under a certain category, the system will try to find{模型table}/list-{分类id}.htmla template format. For example, the category list under the article model with ID 5, the system may search forarticle/list-5.html.
  • Single page detail page:For the single page with ID 123, the system will try to findpage/123.htmlsuch a template file.

These default matching mechanisms greatly simplify the management of general content templates, allowing you to focus only on customizing the display of special content.

Custom template path: finely control the display of your content.

When the default template fails to meet your personalized needs, AnQiCMS allows you to specify a custom template file for specific content through the backend settings.This allows you to achieve highly customized page layouts, such as designing a unique visual style for the "About Us" page, or creating a dedicated display template for a marketing campaign page.

  1. For a single article (or a single document under another content model):When you edit a specific article or product in the "Content Management" section of the background, you will find a collapsible area for "Other Parameters".After expanding, there is a field named "Document Template".In here, you can enter the path of a custom template file.For example, if you want a product article to have a layout specifically for displaying download links, you can create one in the template directoryproduct/download.htmlFile. Then enter the "document template" field of the product article:download.html(relative to the model folder path, orproduct/download.htmlThe path relative to the template root directory, depending on your organization mode and system configuration). When the user accesses this product article, AnQiCMS will use the one you specifyproduct/download.htmlto render the content

  2. List pages for specific categories:In the 'Content Management' 'Document Category' settings, when editing a category, you will also find the 'Category Template' field under 'Other Parameters'. By default, the category list will use{分类模型}/list.htmlAs a template. But if you want to provide a completely different layout for a specific category list page, for example, a product category list containing a large slideshow, you can specify a custom template file here, such asproduct/fancy_list.html. Furthermore, there is also an option for 'whether to apply to subcategories'.Check this box, and this custom category template will be applied to the list page of the current category and all its subcategories, saving the trouble of repeating the settings for each subcategory.

  3. For all articles (or documents under other content models) in a certain category:Next to the "category template" field mentioned above, there is also a "document template" field (in the category settings).The purpose of this field is to, you can specify a default detail template for all articles under a certain category.For example, you have a category named "Case Display" and you want to use the same one for all the case articles under it.article/case_detail.htmlThe template, even if these articles do not have a separate 'document template' set, they will inherit this custom template from the category settings.This is very useful for maintaining visual consistency of a specific content group.

  4. For a single independent page:In the "Page Resources" under "Page Management", when editing a single page, you will also see a "Single Page Template" field. For example, if you want to create a unique layout for the "Contact Us" page that includes a map and a form, you can create it in the template directory.page/contact.htmlThen enter the 'Single Page Template' field on this page.contact.html.

How to specify and apply a custom template

The overall operation process is very intuitive:

  1. Prepare the template file:First, in your AnQiCMS project/templateIn the directory, organize the HTML template files according to your template structure and design requirements. For example, if you want to create a custom template for the article model under the article with ID 10, you may

Related articles

What front-end display modes does AnQiCMS support to manage PC and mobile websites?

In the digital age, it is crucial to provide an excellent user experience whether visitors browse your website on a computer or mobile phone.A high-efficiency content management system should be able to flexibly meet this diverse display demand.AnQiCMS is designed for this, it provides various front-end display modes, allowing you to finely manage the display effects of PC and mobile websites according to your actual business needs.AnQiCMS provides three main display modes on the website frontend, each with unique advantages and applicable scenarios, helping you build a modern website adaptable to different devices

2025-11-07

How to ensure that the AnQiCMS website content can adapt to display on different devices?

With the popularity of mobile internet, the types of devices used by users to access websites are increasingly diverse, ranging from desktop computers to tablet computers, and various sizes of smartphones. Whether the content of a website can be displayed smoothly and beautifully on different devices has become an important standard for evaluating the quality of a website.AnQiCMS (AnQiCMS) was designed with this need in mind, offering flexible and diverse solutions to ensure that website content can easily achieve adaptive display on multiple devices.

2025-11-07

How to get different thumbnail image addresses by using a filter in AnQiCMS template?

When using AnQiCMS for website content management, image management and optimization is a key factor in improving user experience, accelerating page loading speed, and enhancing SEO performance.Especially in the process of template development, we often encounter the need to obtain addresses of different size thumbnails.AnQi CMS provides a straightforward way to handle these issues with its concise and efficient design concept.Today we will delve deeply into how to cleverly use built-in filters in AnQiCMS templates to obtain different thumbnail addresses for the images we upload

2025-11-07

How to use the `yesno` filter of AnQiCMS to display 'yes', 'no', or 'unknown' status based on boolean values in the template?

In AnQi CMS template development, we often need to display different text in a user-friendly manner on the front page according to the boolean (true/false) status of background data, such as "yes" or "no."}Directly displaying `true` or `false` may seem too stiff, and writing complex `if-else` judgment statements can make template code look lengthy.Fortunately, AnQiCMS provides a simple and efficient solution - the `yesno` filter, which can help us easily convert boolean values to custom text states

2025-11-07

How should the template files of AnQiCMS be organized and named to achieve flexible content display?

When using AnQiCMS to build a website, the organization and naming of template files are key to flexible content display, improving website maintenance efficiency and scalability.A well-structured and clearly named template system that not only allows you to easily manage various content types, but also lays a solid foundation for future functional expansion. ### Template File Storage and Basic Conventions AnQiCMS's template system uses a template engine syntax similar to Django, which makes it very亲切 for those familiar with front-end development.All template files should use the `.html` file extension uniformly

2025-11-07

How to use AnQiCMS template tags to dynamically display content data on the front-end page?

## Easily navigate AnQiCMS template tags: make your website content come alive!In today's digital world, a website that can dynamically display content is much more attractive to visitors and improves user experience than a static page.AnQiCMS (AnQiCMS) provides us with a powerful and intuitive template tag system that allows us to flexibly display backend data on the website front-end without writing complex code.This is like having a series of spells that, with a few taps, can bring the website content to life.The template tag design of AnQiCMS has borrowed the syntax of Django template engine

2025-11-07

How to display the title and link of the previous and next articles on the article detail page?

In website operation, the 'Previous' and 'Next' navigation function on the article detail page not only effectively improves the user's reading experience and guides them to continue browsing more content, but also has a positive impact on the website's SEO performance by building internal links.For AnQiCMS users, implementing this feature is simple and efficient.AnQiCMS provides a straightforward and powerful template tag system, making it easy to display the titles and links of the previous and next articles on the article detail page.You do not need to perform complex programming or database queries

2025-11-07

How to display the system name configured in the background of AnQiCMS website?

Conveniently display the system name configured in the AnQiCMS website The system name of the website is a core component of its online identity, it is not just a simple name, but also a key to brand image, search engine optimization (SEO) and user identification.For AnQiCMS users, displaying the system name configured in the background on the website frontend can ensure consistency of website information, enhance user experience, and improve search engine friendliness.

2025-11-07