How to customize parameters in the AnQiCMS backend and display them in the front-end template?

Calendar 👁️ 64

During the operation of a website, we often encounter such needs: the standard content fields (such as title, content, publish time) can no longer meet the needs of personalized display.For example, a product detail page may need to display "manufacturing date

AnQiCMS as a flexible enterprise-level content management system fully considers these custom requirements.It provides powerful features, allowing you to easily create these personalized parameters in the background and safely and conveniently call them to display in the front-end template.

Let's explore step by step how to implement these custom features in AnQiCMS.

I. Set custom parameters in the AnQiCMS backend.

AnQiCMS provides two main ways of custom parameters to meet different application scenarios: custom fields for specific content models (such as articles, products) and global or contact information custom parameters.

1. Content model custom field: Add exclusive properties for specific content types

When you need to add unique information to the content of articles, products, or other custom models, the content model custom fields are the ideal choice.For example, add 'color', 'size', 'material', and other attributes to the 'product' model, or add 'work location', 'salary range', and 'education requirements' to the 'recruitment' model, and so on.

To set these fields, you can go to the back end.Content Managementand then clickContent model. Here, you can choose to edit an existing model (such as 'Article Model' or 'Product Model'), or create a new content model as needed.

After entering the model editing page, you will see a namedCustom fields for content modelarea. Here, you can add new fields:

  • Parameter NameThis is the Chinese name displayed on the backend interface for the administrator to understand its purpose, such as 'article author', 'product color'.
  • Field invocation:This is a very critical item!This field name will be the unique identifier you will use when calling this parameter in the front-end template. It is strongly recommended that you use concise English lowercase letters or camel case naming (such asauthor/productColor). Once set and saved, this field name is usually not recommended to be changed easily, as it directly affects the normal display of the front-end template.
  • Field type: AnQiCMS provides various field types to adapt to different data formats:
    • Single-line text: Suitable for short text input, such as author names, product models.
    • NumberEnsure that the input is purely numeric, such as inventory quantity, price.
    • Multi-line textSuitable for longer descriptions, such as product features, article summaries.
    • Single choice/Multiple selections/Drop-down selectionThese types allow you to preset options, and users can only choose from them.Their option values are entered one per line in the "default value" area, and the system will automatically parse them as selectable items.
  • Mandatory?If this field is crucial for the completeness of the content, it can be made mandatory.
  • Default valueProvide an initial value for the field. For selection fields, here are all the options available.

After completing the custom field settings, when you enter againContent ManagementofPublish documentPage, and when you select a category that belongs to the content model, you will see these custom fields that you just added in the "Other Parameters" collapse box, waiting for you to fill in specific values for each piece of content.

2. Global/Contact Information Custom Parameters: Configure General Website Information

Some parameters are not bound to a specific article or product, but are universal for the entire site, such as additional social media links for the website, special announcement text, or a guide link to a specific page. AnQiCMS is inGlobal SettingsandContact information settingsThe "Custom settings parameters" feature is provided to meet such needs.

  • Global Settings: Find it in the background navigationBackend settings, clickGlobal Settings. Scroll to the bottom of the page, and you will seeCustom settings parametersArea. Here, you can add for exampleHelpUrl(help page link),AnnouncementText(website announcement) and other custom parameters.
  • Contact information settings: Also inBackend settingsclickContact information settings. In addition to the preset contact information on this page, you can also add additional contact information, such asCustom settings parametersadding extra contact methods likeWhatsAppaccounts, specific customer service staff numbers, etc.

Enter custom parameters at these two positions:

  • Parameter Name: It is also the identifier called in the template, it is recommended to use English, for exampleHelpUrl/WhatsAppAccount. The system will automatically convert it to camel case.
  • Parameter valueThis is the specific content of the parameter, such as a URL link, some text.
  • NoteOptional, used to describe the purpose of the parameter for future management.

These global or contact information custom parameters can be called in any template of the entire website, providing a unified and flexible information display for the website.

Second, call the custom parameter display in the front-end template

In AnQiCMS, the front-end template uses a syntax similar to the Django template engine. Variables are enclosed in double curly braces{{变量}}Whereas logical control tags (such as conditional judgment, loop) use single curly braces and percent signs{% 标签 %}.

Understood, we can easily call the custom parameters set in the background in the template.

1. Call the custom field of the content model

For custom fields bound to content models such as articles, products, etc., AnQiCMS provides several ways to call them:

  • Directly by variable name (for the current detail page or list loop)

    If you are on the document detail page(archive.html) and know the name of the custom field's "call field" (for exampleauthor),you can use it directly{{archive.author}}to display its value.

    <p>作者:{{ archive.author }}</p>
    <p>文章来源:{{ archive.source }}</p>
    

    Similarly, if you are in aarchiveListloop (such as displaying a list of articles), you can also access these custom fields through the loop variableitemto access these custom fields:

    {% archiveList archives with type="list" limit="10" %}
        {% for item in archives %}
            <div class="article-item">
                <h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
                <p>作者:{{ item.author }}</p> {# 假设你有一个名为 'author' 的自定义字段 #}
                <p>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</p>
            </div>
        {% endfor %}
    {% endarchiveList %}
    

    For the current document detail page, you can also usearchiveDetailtags to get the value of a single custom field:

    <div>产品颜色:{% archiveDetail with name="productColor" %}</div>
    
  • ByarchiveParamstags to loop through all custom fields (suitable for dynamic display)

    If you are unsure about the custom fields of a content model, or want to dynamically display all custom fields and their values (for example, listing all specifications in a product detail page),archiveParamsTags are very convenient.

    This tag will return an array containing all custom fields, you can go throughforthem in a loop.

    ”`twig {% archiveDetail currentArchive with name=“Id” %} {# Get the current document ID, specify id if not on the detail page #}

    <h3>详细参数</h3>
    {% archiveParams params with id=currentArchive %} {# 使用当前文档ID获取参数,或省略id在详情页自动获取 #}
    <ul>
        {% for item in params %}
            <li>
                <span>{{ item.Name }}:</span> {# 'Name'
    

Related articles

How to build and display the breadcrumb navigation of the current page using the `breadcrumb` tag in AnQiCMS?

In website operation, breadcrumb navigation (Breadcrumb Navigation) is an important element to enhance user experience and website structure clarity.It not only helps visitors quickly understand the position of the current page in the website hierarchy, but also effectively assists search engines in understanding the relationship between website content, and has a positive effect on SEO optimization.For AnQiCMS users, building and displaying breadcrumb navigation is a very convenient operation, thanks to the powerful template tags built into AnQiCMS.### Understand AnQiCMS's

2025-11-09

How to use the `if` tag in AnQiCMS templates for conditional judgment to control content display?

When managing content in AnQi CMS, we often need to display different information based on different situations.For example, a blog post may have a thumbnail, while another does not; or a module may only display under certain conditions.At this time, flexibly using the conditional judgment in the template, that is, the `if` tag, can help us achieve these dynamicized content display needs.The AnQi CMS template engine supports syntax similar to Django, where the `if` tag is the core tool for conditional judgments.

2025-11-09

How to prevent content scraping on the front end in AnQiCMS, such as displaying watermarks or interference codes?

Protect Originality: AnQiCMS intelligent strategy for front-end content collection prevention In the era of explosive Internet content, the value of original content is becoming more and more prominent, but it also faces the risk of malicious collection.The hard work we put into writing and carefully designed images can be stolen in an instant by others, not only infringing on the creators' labor成果, but also potentially affecting the website's SEO performance and brand image.How can we effectively protect our digital assets?AnQiCMS (AnQiCMS) provides a very practical built-in solution to this issue

2025-11-09

How to automatically convert plain text URLs of articles in the AnQiCMS template to clickable hyperlinks?

In daily website content operations, we often need to mention some external links or URLs in articles, product descriptions, or single-page content.If these URLs appear only in plain text, visitors will not be able to click and jump directly, which will undoubtedly affect the user experience, and may even cause some important information to be ignored.AnQiCMS as a powerful content management system, provides a simple and efficient way to solve this problem, making your content more vivid and interactive.AnQiCMS uses a template engine syntax similar to Django

2025-11-09

How to implement scheduled publishing of articles in AnQiCMS to ensure that content is visible on the front page at specified times?

As a content operator, we know that in the age of information explosion, the timing of content release often determines its dissemination effect.In order to coordinate with market activities, maintain a stable update frequency, or publish important announcements at specific times, a function that can accurately control the publication time is indispensable.AnQiCMS (AnQi Content Management System) is well-versed in this, providing us with a simple and powerful scheduling mechanism to ensure that every meticulously prepared article is presented to the reader at the most appropriate time.Use AnQiCMS for timed publishing

2025-11-09

How to iterate over an array or slice in AnQiCMS template and loop through its elements?

In the AnQi CMS template world, dynamically displaying content is the key to building an active and feature-rich website.Whether it is an article list, product display, navigation menu, or image gallery, we need a mechanism to traverse the data set and display each element on the page.Fortunately, the template engine of Anqi CMS provides an intuitive and easy-to-use loop structure, allowing us to easily achieve this goal.

2025-11-09

How to define variables and display their values in AnQiCMS templates?

In AnQiCMS templates, we often need to handle various data, whether it is the name of the website, the title of the article, or the product details, these dynamic contents all need to be carried and displayed through variables.Understanding how to define and display variables in templates is the core of AnQiCMS template development.AnQiCMS adopts a syntax similar to the Django template engine, making the use of variables intuitive and easy to pick up.In the template file (usually in `.html` format, stored in the `/template` directory)

2025-11-09

How to set up an independent template for a single page in AnQiCMS and display its content correctly?

In AnQiCMS, single pages (such as "About Us", "Contact Information", or specific product landing pages) are an important part of our website content.They usually carry unique information and need to have a different layout and visual style from other content on the website (such as article lists or product details).Fortunately, AnQiCMS provides极高的flexibility, allowing you to easily set up a dedicated independent template for each single page, thereby creating a unique user experience.### AnQiCMS template base

2025-11-09