Unlock AnQiCMS layout cube:extendsHow to realize the differentiated design of content pages with tags

As an experienced website operations expert, I am well aware that the presentation of website content is crucial for user experience and brand image.How to maintain a unified style on a website filled with various types of content, while also allowing different types of content (such as in-depth articles, product introductions, event details) to have unique display pages, this is undoubtedly a challenge faced by many operators.In AnQiCMS (AnQiCMS), the core template inheritance mechanism, especiallyextendsThe clever use of tags is the key to solving this problem.

extendsThe core concept: building the skeleton and flesh of the page

Imagine that we are designing a magnificent building. Before we start construction, we first need a master plan that defines the overall structure of the building - where the main hall is, where the load-bearing walls are, and where the roof is.This blueprint, is the 'benchmark template' in our website template, usually named asbase.html.

In the AnQiCMS template system,extendsThe tag is used to declare that a template is an extension of another template. It's like telling the system: 'Hey, this page is based on'base.htmlThis grand blueprint is built. This way,base.htmlCommon elements defined, such as headers, footers, sidebars, or navigation menus, do not need to be written repeatedly on each page, but are automatically owned by all pages that inherit it.

So, how is differentiation achieved? The answer is hidden inbase.htmlof{% block ... %}the tags. TheseblockLabels are like 'customizable areas' reserved on architectural blueprints, such as 'living room area', 'bedroom area', etc. Inbase.htmlwe might define a{% block content %}{% endblock %}To serve as the main content area of the page, or{% block title %}{% endblock %}To define the page title.

When a page (such asarticle/detail.htmlorproduct/detail.htmlPassed{% extends 'base.html' %}inherits the base template, it can optionally choose to 'fill in' or 'override' theseblockArea. If it does not cover a certainblockthen the area will be displayedbase.htmlDefault content is preset; if it is overwritten, it will display its own customized content, thus achieving differentiation in layout.

Achieve differentiation: tailor-made for different content types.

The flexible content model feature of AnQiCMS provides a solid foundation for differentiated page layouts.The system is pre-installed with article and product models, but operators can customize more content models according to their business needs.This means not only can manage data of different structures, but also means can be designed for these different types of content dedicated display page.

For example, for anarticle detail pagewe usually need to highlight the author information, publishing time, related articles list, and comment section. Therefore,article/detail.htmlthis template may inheritbase.htmlafter,{% block content %}Contains the following elements:

  • Article title ({% archiveDetail with name="Title" %})
  • Date of publication, category and tags ({% archiveDetail with name="CreatedTime" %}/{% categoryDetail with name="Title" %}/{% tagList %})
  • Main content ({% archiveDetail with name="Content" %}|safe)
  • Previous/next article link ({% prevArchive %}/{% nextArchive %})
  • Recommended articles ({% archiveList with type="related" %})
  • Comment form and list ({% commentList %})

And in oneProduct details pagefor exampleproduct/detail.html), the core of the page is the display and conversion of the product. It inheritsbase.htmlAfter that, its{% block content %}The structure will be quite different:

  • Product name ({% archiveDetail with name="Title" %})
  • Product album or carousel ({% archiveDetail with name="Images" %})
  • Price, inventory, SKU information ({% archiveDetail with name="Price" %}/{% archiveDetail with name="Stock" %})
  • Product parameter table or list ({% archiveParams %})
  • Product Description or Selling Points ({% archiveDetail with name="Description" %})
  • “Add to Cart” or “Buy Now” Button
  • Detailed Product Specifications, Instructions, etc ({% archiveDetail with name="Content" %}|safe)

ByextendsThe application of tags allows us to easily create different content area layouts for articles and product pages, while common elements such as headers, footers, and navigation remain consistent, greatly enhancing the efficiency of design and development.

Refine to individual content or category: deeper customization

The power of AnQiCMS is far more than defining a universal layout for "model".Sometimes, we may need to design a unique page for a specific article, product, or even a category.For example, a single-page company annual report, a dedicated detail page for a new hot product, or a special event topic category.

According to the document instructions, AnQiCMS supports setting up through the backend forSingle document/specific categoriesorSingle pageSpecify a custom template. This means that evenarticle/detail.htmlis a general template for articles, we can still specify a123template for the article "AnQiCMS v3.0 release" with IDarticle/detail-v3-release.htmlof an independent template. Similarly,page/about.htmlcan provide a special display for a single page "About Us".

These custom templates can still be utilizedextendswith its powerful capabilities. For example,article/detail-v3-release.htmlcan inheritarticle/detail.htmlThen only modify a specific oneblockFor example, add a sidebar of "New Feature Highlight"blockor adjust the layout of the main content area to highlight the video introduction.This hierarchical inheritance mechanism ensures that the basic structure and common functions of the page can be effectively reused and managed regardless of the level of customization.

Layout consideration under operational strategy

From an operational perspective,extendsThe layout differentiation brought by labels has profound significance:

  1. User Experience Optimization:Different types of content adapt to different information structures and interaction methods, making it easier for users to obtain the information they need.The article focuses on reading, the product focuses on understanding and purchasing, and the page layout should serve these core goals.
  2. SEO friendliness: base.htmlCan unify the generation logic of TDK (title, keywords, description) to ensure that all pages have the basic SEO structure.blockCustomization allows different content types to be optimized for SEO in detail, for example, product detail pages can focus more on product models and purchase intent keywords.
  3. Consistency and flexibility coexist:The brand's visual recognition and core navigation are unified through the basic template, but the content presentation can also be flexibly adjusted according to the operational strategy, avoiding the boredom of being 'one size fits all'.
  4. Development and maintenance efficiency:Developers only need to focus on filling or overriding specificblockInstead of starting from scratch to build each page, it greatly shortens the development cycle and reduces maintenance costs. When a global modification is needed (such as changing the logo or adjusting the footer information), it is only necessary to modifybase.htmlJust as it is, without touching all sub-templates.

Summary

In AnQiCMS,extendsLabels are not just simple template instructions; they are more like the core pivot of a 'layout magic cube'.By establishing a clear template inheritance relationship, we are able to build highly differentiated and function-focused display pages for different content types such as articles, products, and single pages while maintaining the overall consistency of the website.From macro-level general layout to micro-level content customization,extendsWith its flexible and powerful mechanism, empowering AnQiCMS users to achieve a double leap in efficiency and innovation in content operations.Grasp the essence of it, and you will be able to better handle AnQiCMS, creating a beautiful and efficient website content presentation scheme.


Frequently Asked Questions (FAQ)

1. Can I create completely independent baseline templates for different modules (such as articles and products), rather than inheriting the same one?base.html?

Of course you can. Although it is usually recommended to use a primarybase.htmlTo maintain the global consistency of the website, but in certain special cases, if you want the article module and the product module to have a completely different overall framework (for example, completely different navigation structures or header and footer styles), you can create multiple independent base templates, such asarticle_base.htmlandproduct_base.html. Then, let each detail page (such asarticle/detail.html) inherit