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.