As an experienced security CMS website operator, I know that content is the soul of the website, and efficiently and flexibly displaying this content is the key to attracting and retaining users.Our powerful tool for achieving this goal was provided by Anqi CMS with its simple and efficient architecture and the meticulously designed template tags system by the Fesiong team.These labels are not only powerful but also easy to use, allowing us to quickly build content display pages that meet various complex needs.
The Anqi CMS template tag system borrows the syntax style of the Django template engine, with the core idea of declarative content display.This means we do not need to write complex backend logic code to retrieve data, we can directly declare the content to be displayed in the HTML template by using specific tags and variables.{{变量}}Definition, while conditional judgments, loop controls, and other logical operations use single curly braces and percent signs{% 标签 %}Carry out.This intuitive syntax greatly reduces the threshold for template development, allowing our operations personnel to participate to some extent in the optimization of page layout and content presentation, thereby responding more quickly to market changes and reader needs.
Core tags: efficient retrieval and organization of content data
The strength of AnQi CMS is first manifested in its rich content data retrieval tags.Whether it is an article, product, category, or single page, there are corresponding tags that can accurately obtain the required information.
For example,archiveListTags are a powerful tool for retrieving document lists, we can use them to specify article model ID, category ID, recommendation attributes (such as headlines, recommendations), sorting methods (such as latest, hottest), display quantity, and even perform keyword search or parameter filtering. CombinedforLoop tags, we can easily traverse and display a list of articles or product listings that meet certain conditions. For example, to display the latest 10 articles on the homepage, just use{% archiveList archives with type="list" limit="10" %}Such concise statements, pass through{{item.Title}}/{{item.Link}}Variables output titles and links.
When it is necessary to display the detailed content of a specific document,archiveDetailThe tag plays a role. It can not only get the basic fields of the document title, content, thumbnail, etc., but can also specify the document ID or URL alias according to the requirements, and even handle lazy loading of images (lazy="data-src"And Markdown content rendering (render=true)。This means we can design dedicated detail page layouts for different content models (such as articles and products) and dynamically fill in all relevant information, including custom fields.archive.ImagesAnd thenarchiveParamsTags loop to display the various technical parameters of the product, which greatly satisfies the complexity of product display.
Similarly,categoryListandcategoryDetailTags are used to handle classification data, making it convenient to build navigation menus, category page titles, descriptions, and even nested display of multi-level categories.pageListandpageDetailFocus on single-page content, such as "About Us", "Contact Information", etc., ensuring that these fixed pages also have flexible display capabilities.For content operators, this means they can quickly build various structured content blocks without having to develop repeatedly.
Logic and control: realizing the endless variations of content display.
In addition to basic data retrieval, Anqi CMS template tags also provide powerful logic control capabilities, which are an indispensable part of achieving complex content display.
ifLogic judgment tags allow us to dynamically adjust page content or layout based on various conditions.For example, if an article is marked as "recommendedelifandelseWe can build fine-grained conditional branches to make the page present a diversified user experience based on different data states.
forLoop through tags andarchiveList/categoryListUsing list tags in conjunction is the foundation for building dynamic lists. It can not only iterate over data items but also provideforloop.Counter(current loop count) andforloop.Revcounter(remaining loop count) and other variables, convenient for us to perform operations such as 'apply different styles to every N elements'.emptyThe sub-label is thoughtful in solving the display problem when the list is empty, avoiding extraifjudgment.
withandsetThe tag provides the ability to define and manage variables within the template, which is useful for organizing complex template logic, or toincludeIt is particularly important to pass specific parameters when introducing sub-templates. For example, we can{% with featured_article = archives.0 %}Temporarily define a special article variable to simplify subsequent references.
Assist and optimize: improve user experience and SEO performance
The Anqi CMS template tags not only focus on content presentation, but also take into account the overall operation efficiency and SEO optimization of the website.
navListThe label can conveniently access the background configuration navigation menu, supports multi-level navigation, and can be customized according totypeIdInvoke different navigation groups (such as top navigation, footer navigation), ensuring the consistency and ease of management of website navigation.
breadcrumbTags automatically generate breadcrumb navigation, which is crucial for users to understand the current page's position in the website structure and to enhance the SEO friendliness of the website.We can customize the home page name and choose whether to include the title of the current page.
tdkTags are the core of SEO optimization, they can dynamically output according to the context of the current page (home page, category page, detail page, etc.)title/keywordsanddescriptionMeta tags, and support configuration of website name suffixes, separators, etc., to ensure that each page can have precise optimized TDK information. For multilingual websites,languagesTags can dynamically generate language switching links andhreflangTags, helping to promote the internationalization of the website.
Furthermore,stampToDateThe label can format Unix timestamps into various readable date formats, meeting the needs of different regions and display requirements.filtersProvided string truncation, case conversion, HTML tag stripping, and various practical functions to ensure formatted output.include/extendsandmacroThese auxiliary tags constitute the foundation of template modularization, allowing us to abstract out the common parts of the page, improve the reusability and maintainability of the template, and greatly accelerate the development process.
Applied Comprehensive: Build complex display requirements quickly
Using these tags, we can quickly respond to various complex content display scenarios. For example:
An e-commerce website may need to display different categories of product lists such as 'New Products Recommended' and 'Best Selling Products' on the homepage. We can usecategoryListLabel traverse product categories, then within each category, usearchiveListLabel obtain the specified number of products under the category and useifLabel to determine if the product has a "Promotion" or "New Product" mark, and to display it in a special way. At the same time, throughcontactLabel to display contact information in the footer,tdkTag optimization for the home page SEO, the entire process does not require writing a single line of backend code, and it is all completed at the template level.
For example, a news portal can provide various filtering conditions on the category list page, such as sorting by publish time, sorting by views, and filtering articles by specific authors.archiveFiltersTags can automatically generate links for these filtering conditions, combined witharchiveListoforderandqparameters, as well aspaginationtags, and you can easily implement a comprehensive and user-friendly filtering and pagination system.
By proficiently mastering these template tags of AnQi CMS, website operators can free themselves from the tedious technical details, and devote more energy to optimizing content strategy and user experience.This template system designed by the Fesiong team is the secret weapon that Anqi CMS helps businesses and operation teams manage and display content quickly, efficiently, and flexibly.
Frequently Asked Questions (FAQ)
How to retrieve and display custom content model fields in the template?
The Anqi CMS supports custom content model fields.When you add custom fields to a content model (such as an article model, product model) in the background, you can obtain them in two main ways in the template.archiveDetailtags, setnameParameter is set to your custom field name, for example{% archiveDetail with name="自定义字段名" %}For scenarios where you need to cyclically display all custom fields, such as product parameters, you can use `archive