How to use AnQiCMS template tags to flexibly display different types of content?

Calendar 👁️ 67

AnQiCMS as an efficient and flexible content management system, its template tag system is the key to our website content operation and display.It provides a set of intuitive and powerful tools that allow us to present the content of the background management in various styles according to different scenarios and needs, thereby greatly enhancing the flexibility and user experience of the website.

In AnQiCMS, content is not just simple articles or news, thanks to itsFlexible content modelWe can create articles, products, events, and various types.How to accurately present this rich and diverse content is where template tags play their role.They are like bridges connecting backend data with the frontend interface, with simple syntax, they can convert complex database information into easy-to-understand and display page elements.

To flexibly display different types of content, we first need to be familiar with the basic usage of AnQiCMS template tags. The core syntax structure is divided into two types: used for outputting variablesdouble curly braces{{ 变量名 }}and used for controlling logic (such as loops, conditional judgments) ofsingle curly braces percentage{% 标签名 参数 %}. Having mastered these two forms, we can build pages like building blocks.

Accurately display a single item: The art of the detail page

When we talk about displaying specific content, such as a detailed article or a product introduction,archiveDetailTagIt is an indispensable tool.It can retrieve all the details of the content based on the document ID of the current page (or a specified ID).Imagine you are releasing a new product that needs to display its name, images, detailed description, and unique selling points.archiveDetailWe can easily obtain:

  • Title and description: {{archive.Title}}and{{archive.Description}}The product name and introduction will be output separately.
  • Picture display: {{archive.Logo}}Used to display the main product image,{{archive.Thumb}}Used for thumbnails, even multiple product images can be displayed througharchiveImagesa variable for loop display.
  • Content主体: {{archive.Content|safe}}Will output a product introduction that has been rendered with HTML, ensuring consistent layout and style.
  • Custom parameters:AnQiCMS is a major highlight that supports customizable content model fields. If you add custom fields such as "material", "color", "size", etc. to your product model, you can usearchiveParamsLabel to display uniformly or use directly{{archive.你的自定义字段名}}To accurately call a field's value, greatly enriching the information presentation of the product details page.

In addition, we can also take advantage ofprevArchiveandnextArchiveTagShow the previous and next content to guide users to continue browsing and increase the stickiness between pages.

Dynamically present a collection of content: the charm of the list page.

The majority of the website's pages are content lists, such as news centers, product categories, case displays, and so on.archiveListTagIt is the core of building these lists. It supports various parameters to filter and sort content, helping us to achieve diverse list displays:

  • Specify the content model and classification:BymoduleId(such as article model ID or product model ID) andcategoryIdParameters, we can accurately pull the content list belonging to a specific model or category. For example, only display all products under the 'Electronics' category.
  • Sorting and filtering: orderParameters allow us to sort by publish time, views, and more, andlimitcontrol the number of items displayed per page. More advanced usage involves combining query parameters in the URL, throughqPerform keyword search, or filter by custom fields to achieve highly customized content filtering functions.
  • Pagination processing:WhenarchiveListoftypethe parameter topageIt will cooperate when,paginationTagAutomatically generate pagination navigation, allowing users to easily browse a large amount of content.

In addition to the regular articles and product lists, AnQiCMS also providescategoryListTagDisplay category information (such as displaying all first-level categories or subcategories under a parent category),pageListTagUsed to list all single pages (such as About Us, Contact Information), as well astagListandtagDataListTagDisplay popular tags or all content under a specific tag to improve the website's navigation and content aggregation features.

Unified and convenient global information and auxiliary content for the website.

Some websites have common information such as navigation menus, contact information, website name, filing number, etc., which need to appear frequently on multiple pages. AnQiCMS provides special tags to handle these global content, ensuring consistency and ease of maintenance:

  • Navigation menu: navListTagYou can flexibly generate the top, bottom, or sidebar menu of the website according to the navigation category configured in the background, and it supports multi-level dropdown menus.
  • Contact Information: contactTagConveniently access contact information such as phone numbers, addresses, emails, even social media links (such as WhatsApp, Facebook) and QR codes, allowing users to easily obtain contact information at any time.
  • System Settings: systemTagCan retrieve the website nameSiteNameLogoSiteLogo, Record numberSiteIcpand global configurations to ensure the unified display of brand information.
  • TDK Information: tdkTagHelp us get the page's Title, Keywords, and Description, which is crucial for SEO optimization, and it can also intelligently combine the website name and content title.

A tool to enhance development efficiency: Advanced application techniques

In addition to the aforementioned feature tags, the AnQiCMS template also provides many auxiliary advanced techniques to make template development more efficient and professional:

  • Conditional judgment and loop control:Flexible applicationif/elif/elsePerform conditional judgment, as well asforLoopTraverse the data list and adjust the content display dynamically according to different business logic. For example, judge whether the product has stock, or add a special style to the first item in the list.
  • Filter:AnQiCMS has built-in rich filters that can be used for secondary processing when outputting content. For example,stampToDateFilters can format timestamps into readable dates;safeThe filter is used to output HTML content without escaping;truncatecharsThe long text content can be truncated and an ellipsis can be automatically added;dumpThe filter can help us view the structure and value of variables during development and debugging.
  • Template inheritance and reference: extendsandincludeTagIs the key to building maintainable and reusable templates.extendsAllow us to define a basic layout (skeleton), other pages inherit this layout, and only cover the parts that need to be customized (viablocktag definition).includeYou can extract common code snippets (such as headers, footers, sidebars) and reference them where needed to avoid duplicate code.

By combining these template tags, we can easily handle the content management capabilities of AnQiCMS, whether it's building a rich content information portal, a functional e-commerce website, or a simple and clear corporate website, it can achieve highly customized and flexible content display to meet the ever-changing operation needs.


Frequently Asked Questions (FAQ)

  1. Why did the front page of the website not update immediately after I modified the template file?Answer: AnQiCMS usually has a caching mechanism to improve website performance.If you modify the template file and there is no change on the front end, please try to find the 'Update Cache' or 'Clear Cache' feature in the AnQiCMS admin interface, click to execute and refresh the front-end page.This usually solves the problem of不及时 template updates.

  2. Ask: InarchiveListorcategoryListTag, how to get the corresponding article ID or category ID of the current page?Answer: The current article ID can be accessed directly through the article detail pagearchive.IdObtained; In the category list page or category detail page, the current category ID can be accessed throughcategory.IdRetrieve. These variables are usually automatically injected into the page context. If you need to retrieve in a general template, you can try toarchiveListorcategoryListofcategoryIdLeave the parameter blank, the system will automatically try to read the category ID of the current page.

  3. Ask: How can I call and display custom fields (such as "product materialAnswer: On the content detail page (such as an article or product detail page), you can use it directly{{archive.您的自定义字段名}}to call. For example, if you create a field namedproduct_materialyou can use it directly in the template{{archive.ProductMaterial}}(Note that it will be automatically converted to camel case). If you need to loop through all custom fields, you can usearchiveParamsLabel, it will return an array containing all custom field names and values, you can iterate throughforLoop through the display.

Related articles

How to customize the display layout of the website page in AnQiCMS?

AnQiCMS provides very flexible and powerful custom layout capabilities for website pages.Whether you want to quickly build a corporate website with a unique style or need to finely operate multi-site content, AnQiCMS can give you complete control over the 'skeleton' to 'flesh' of the website.### Core Concept: Comprehensive Control from Skeleton to Detail The customization ability of AnQiCMS is mainly reflected in the use of the Django template engine syntax, which is natural and smooth, easy to learn, even if you are not a professional backend developer

2025-11-07

How to use the timed publishing feature in AnQiCMS to accurately

Today, in the increasingly refined field of content marketing, both the quality of the content and the timing of its dissemination are equally important.A well-crafted content, if released at an inappropriate time, may not achieve the expected communication effect.AnQiCMS is an efficient management system designed specifically for content operators, deeply understanding this field, and its built-in scheduling publication function is the key tool to help us accurately grasp the 'golden moment' of content marketing.The core concept of the scheduled publishing function is to make content going online no longer limited by manual operation time.

2025-11-07

How to set up the website navigation menu in AnQiCMS and support multi-level dropdown display?

The website navigation is the first window for users to interact with the website, a clear and intuitive navigation design can greatly enhance the user experience and effectively guide them to find the information they need.In AnQiCMS, setting up the website navigation menu and supporting multi-level dropdown display is a flexible and practical feature.Next, we will explore how to achieve this goal in AnQiCMS together. ### Build the backend logical structure of the website navigation To create and manage the navigation menu in AnQiCMS, you need to enter the "Navigation Settings" area of the backend.

2025-11-07

How to add thumbnails to articles and products on the AnQiCMS website and control their frontend display styles?

Managing website content in AnQiCMS, thumbnails are undoubtedly an important element in enhancing user experience and page attractiveness.Whether it is an article that attracts users to click or a detailed page that showcases product features, a suitable thumbnail can play a huge role.What is even better is that AnQiCMS provides an intuitive backend operation and flexible template tags, allowing us to easily add thumbnails to articles and products and finely control their display styles on the front end.

2025-11-07

What template file types and organization modes does AnQiCMS support to control the display of the page?

## AnQiCMS template files and organization methods: The secret to flexible control of page display In the digital age, the visual presentation and content layout of a website are the core of attracting users and conveying information.An excellent content management system should also provide highly flexible page display control capabilities, in addition to powerful content management functions.AnQiCMS is designed based on such an idea, it not only makes content publishing efficient, but also gives users the powerful ability to customize the appearance of the website at will through its unique template file type and organizational mode.

2025-11-07

How to create and manage multiple sites in AnQiCMS to achieve independent content display?

AnQiCMS is an efficient enterprise-level content management system, and its multi-site management function is undoubtedly an important tool for many enterprises and operators to improve efficiency and segment the market.By creating and managing multiple independent sites under an AnQiCMS instance, we can flexibly provide customized content display and services for users of different brands, business lines, or regions.

2025-11-07

How does AnQiCMS handle images in document content to optimize front-end display (e.g., Webp, compression)?

Images are an indispensable part of website content, they can make the page more attractive and convey richer information.However, if images are not optimized, the large file size often leads to slow website loading, severely affecting user experience and search engine rankings.AnQiCMS provides a series of powerful optimization functions when processing images in document content, helping us easily cope with these challenges to ensure that the front-end display is both beautiful and efficient.

2025-11-07

How to set up independent display templates for AnQiCMS documents or categories?

In website operation, we often encounter such needs: some documents need a unique display method, the article list of a certain category needs a special layout, or a single page needs a unique design.AnQiCMS knows the importance of this personalized demand and provides flexible template settings to easily set independent display templates for documents, categories, and even single pages.This can not only help you better meet the diversity of content display, but also greatly enhance the user experience and the brand image of the website.Why do we need an independent display template?

2025-11-07