How to force all English text in the AnQiCMS backend custom fields to lowercase?

Calendar 👁️ 72

In website content operation, maintaining consistency in text format is a key step to improving user experience and SEO effectiveness.Sometimes, we may encounter such a requirement: we hope that the English text entered in the custom field of the background can be forced to be displayed in lowercase on the front end regardless of how the user enters it.This not only makes the page look neater and professional, but also helps avoid SEO problems caused by inconsistent capitalization.

幸运的是,AnQiCMS provides a very flexible content management solution, with its powerful template engine and built-in filters, we can easily achieve this goal.

Understand AnQiCMS custom fields

AnQiCMS is positioned to serve small and medium-sized enterprises and content operation teams, it allows us to highly customize the content structure according to business needs.In the background, in the "Content Management" -> "Content Model", we can add dedicated fields for articles, products, or other custom models.These custom fields greatly enrich the expression of content, such as product models, brand names, product codes, etc., which may contain English text.

For example, if you create a custom field named "Product Code" and set its "Call Field" toproductCode. Users may enter "ABC-123", "abc-123", or "Abc-123" at the back end, but in order to display them uniformly, we hope they can all be displayed as "abc-123"。

The wonders of template engine and filters

AnQiCMS uses a syntax similar to the Django template engine, which is a powerful and easy-to-use feature that allows us to handle data flexibly at the content display level.Among them, 'Filters' is the tool we use to implement text format conversion.The AnQi CMS includes a variety of practical filters, including one namedlowerThe filter, its function is to convert all uppercase letters in a string to lowercase.

We do not need to modify the original data in the database or write complex backend code to force the English text of the custom field to lowercase. Simply find the output location of the corresponding custom field in the template file and apply it cleverlylowerthe filter.

Practical steps: Convert custom field text to lowercase

Let's go step by step to see how to implement:

  1. Determine the call location of the custom fieldFirst, we need to determine in which template file the custom field is, and through which tag it is called. Usually, custom fields are called througharchiveDetailorarchiveParamsTags are displayed on the article or product details page.

    • If you are directly calling a custom field (such asproductCode), it may look like this:{% archiveDetail productCode with name="productCode" %}{{ productCode }}

    • If your custom field is part of the "other parameters" passed througharchiveParamsThe label will be cycled through and displayed, and it may look like this:{% archiveParams params %}{% for item in params %}<span>{{ item.Name }}:</span><span>{{ item.Value }}</span>{% endfor %}{% endarchiveParams %}

  2. applylowerFilterAfter determining the call location, the next step is to add it at the place where the custom field value is output.|lowerfilter.

    • For the case of direct calling, add it after the variable.|lowerJust do it: {{ productCode }}is modified to{{ productCode|lower }}The complete code snippet may become:

      {% archiveDetail productCode with name="productCode" %}
      产品编码:{{ productCode|lower }}
      
    • For those who passarchiveParamsThe same loop iteration situation applies initem.Valueadd|lower: To be<span>{{ item.Value }}</span>is modified to<span>{{ item.Value|lower }}</span>The complete code snippet may become:

      {% archiveParams params %}
      {% for item in params %}
      <div>
          <span>{{ item.Name }}:</span>
          <span>{{ item.Value|lower }}</span>
      </div>
      {% endfor %}
      {% endarchiveParams %}
      
  3. Save and update cacheAfter modification, remember to save the template file. Then, an extremely important step is: clear the system cache of AnQiCMS.At the bottom of the left menu in the background, you will find the 'Update Cache' option, click it to clear all the cache.After that, refresh your website's front-end page, and you should be able to see that all the English text in the custom fields has been forcibly converted to lowercase.

This method only changes the display effect on the front-end, the original data stored in the back-end database (including case) will not be affected, which preserves the originality of content editing while ensuring the standardization of front-end display.

Some important considerations

  • Caching mechanism:AnQiCMS to improve performance, uses caching.Therefore, after each modification of the template file, you must click "Update Cache" in the background to clear the old cache data, otherwise you may not see the modified effects immediately.
  • Global and Local:This transformation is for what you added in the template:|lowerFilter

Related articles

How to automatically capitalize the first letter of the English name submitted by the user in the AnQiCMS template?

In website operation, we often encounter the need to display user submitted information, such as name.In order for this information to look more professional and unified, it is usually desired that the first letter of the English name be automatically capitalized.This not only enhances the beauty of the user interface, but also ensures the consistency of data display.In the flexible template system of AnQiCMS, implementing this requirement is very simple.

2025-11-07

How to remove only specific types of HTML tags in the AnQiCMS template (such as `<i>` or `<strong>`)?

In the template development of Anqi CMS, we often encounter the need to handle content output by rich text editors.This content usually includes various HTML tags, such as those used for emphasizing `<strong>`, for italicizing `<i>`, or others like `<em>`, `<span>`, `<div>` etc.

2025-11-07

How to batch remove all HTML tags from product descriptions in AnQiCMS and retain only plain text content?

In website operation, we often encounter the situation that product descriptions contain a large number of HTML tags.These tags may come from different content sources or may be accidentally introduced during the editing process, leading to poor display of the description in some scenarios, such as plain text email notifications, SEO summaries, or concise views on mobile devices.AnQi CMS provides a flexible way to solve this problem, whether it is to dynamically display plain text on the front end through templates or to perform batch processing on the back end, completely removing redundant HTML tags.

2025-11-07

In AnQiCMS template, how to truncate article titles by word and display an ellipsis to adapt to different layouts?

In modern web design, the flexibility of content display is crucial, especially for core elements like article titles.When the article title is too long and our layout space is limited, how to elegantly truncate the title and add an ellipsis so that it maintains readability and adapts to different devices and layouts is a problem often encountered in the development of AnQiCMS templates.Luckyly, AnQiCMS's powerful template engine provides a simple and efficient solution.

2025-11-07

How to implement capitalizing the first letter of each word in the article title in AnQiCMS templates?

In website content operation, the standardization of article titles is often a key factor in improving the professionalism and user experience of the website.A neat and consistent title format not only makes the content more attractive but also helps improve the overall image of the website.AnqiCMS provides us with a very concise and efficient solution, which can easily capitalize the first letter of each word in the article title with a simple filter in the template.

2025-11-07

How to quickly remove spaces or specific characters from both ends, left or right of a string in AnQiCMS template?

In content management, we often encounter situations where there are excessive spaces or unwanted specific characters at both ends of strings, which not only affects the display aesthetics of the content, but also sometimes causes unnecessary interference to data processing or search engine optimization (SEO).AnQiCMS uses a template engine syntax similar to Django, providing us with concise and efficient filters (Filters) to easily solve these problems.This article will introduce how to quickly remove spaces or specific characters from both ends, left, or right of a string in the AnQiCMS template.

2025-11-07

What is the correct syntax for using the `{{ obj|filter__name:param }}` filter in AnQiCMS templates?

AnQiCMS (AnQiCMS) provides strong support for content operations with its efficient and flexible features.In daily content display, we often need to process and format data in a fine-grained manner to ensure that information is presented to visitors in a **state**.At this moment, the 'filter' in the template has become an indispensable tool for us. Today, let's delve into the correct syntax for using filters in Anqi CMS templates: `{{ obj|filter_name:param }}`.Understand and master it

2025-11-07

How to set a default friendly display value for a possibly empty variable in AnQiCMS template?

When building website templates, we often encounter situations where a variable may be empty in the template due to unentered data, optional fields left blank, or specific business logic.If these empty variables are not processed, the front-end page of the website may appear blank areas, display unfriendly placeholders, and even cause layout errors, thereby affecting user experience and the professionalism of the website.

2025-11-07