Does the `languages` tag in AnQiCMS support any parameter settings?

Calendar 👁️ 72

AnQi CMS, as an enterprise-level content management system, performs well in helping enterprises with global content layout, and "multi-language support" is one of its core advantages. When developing templates for AnQi CMS, we often encounter the need to display or switch the website language, at which point we can't help but mention a key template tag -languages.

AnQiCMS inlanguagesThe core function and design concept of the tag

Directly answer the questions that everyone cares about:In AnQiCMSlanguagesThe tag does not support any parameter settings.

This initially sounds surprising, after all, we are accustomed to many list labels that can be passed throughlimit/categoryId/orderFine-tune parameters for precision control. However, this is not a lack of AnQiCMS features, but rather an embodiment of its design philosophy.languagesThe responsibility of tags is very clear and single:Get the list of all multilingual sites configured in the current system.

ImaginelanguagesThe tag is like a loyal messenger, whose task is not to order dishes in the kitchen (set parameters), but to bring back the list of all ready dishes from the kitchen unchanged (list of multilingual site lists).The development team of AnQiCMS places the definition and management of multilingual sites at a more macro level, namely through the background multi-site management feature to create, configure, and activate different language versions.Once these language sites are set up in the background,languagesThe tags can accurately capture this information.

This 'parameterless' design simplifies the development complexity of the front-end template because you don't need to worry about how to filter or sort the language list - it always provides a complete, system-defined language set. Your main task is to make use of this data and display it in a user-friendly manner, such as building a language switcher or generating for SEO.hreflang.

The powerful application of “no parameters” is to utilizelanguagesTag to implement multilingual functionality

ThoughlanguagesThe tag itself has no parameters, but the rich data fields it provides are enough to support various complex language switching and SEO needs. It returns an array object, eachitemRepresents a language site, including the following key fields:

  • LanguageName: The language name of the site (e.g. "Chinese", "English").
  • Language: The ISO code for languages (e.g. 'zh-CN', 'en-US'), often usedhreflangProperty.
  • LanguageEmoji: The Emoji symbol for language (e.g. 🌐).
  • LanguageIcon: Language corresponding icon URL, if configured.
  • Name: The name of the site.
  • Link: Link address of the corresponding language site.
  • Remark: Link remark information.
  • Nofollow: Whether it isnofollowLinks, usually used for SEO control.

Let's take a look at how we can cleverly use these fields:

1. Build a language switcher

This is the most common application scenario. By traversinglanguagesThe tag retrieves the list of sites, and we can easily create a language selection menu, allowing users to freely switch between different language versions.

{%- languages websites %}
{%- if websites %}
<div class="language-switcher">
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}" class="language-item">
        {%- if item.LanguageIcon %} {# 优先显示图标,如果没有则显示Emoji #}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}" class="language-icon" />
        {%- else %}
        <span class="language-emoji">{{item.LanguageEmoji}}</span>
        {% endif %}
        <span class="language-name">{{item.LanguageName}}</span>
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

In this code, we first go through{%- languages websites %}Get all language sites and assign them towebsitesVariable. Then, use{%- for item in websites %}Loop through each language site and useitem.LinkGenerate a jump link,item.LanguageIconoritem.LanguageEmojiDisplay the language identifier, as well asitem.LanguageNameDisplay language name. Implemented language switching simply and efficiently.

2. Achieved SEO-friendlyhreflangTag

For multilingual websites,hreflangTags are the key to search engines understanding the association of content in different language versions.It tells the search engine that the specific page has other language versions, thus avoiding duplicate content issues and ensuring that users can access the page most suitable for their language or region.languagesTags can help us dynamically generate these tags, placed in the HTML's<head>Area:

{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}

This code will generate a tag for each configured language site<link rel="alternate" hreflang="xx">to ensure that search engines can correctly identify and index all language versions.item.LinkProvided the complete URL of the corresponding language page, whileitem.Languagethen provided the standard language code.

Deeply understand the multilingual mechanism of AnQiCMS

AnQiCMS is able tolanguagesThe tag is so concise, thanks to its perfect multi-site management function in the AnQiCMS backend. In the AnQiCMS backend, you can:

  1. Configure the default language package in the global settingsThis affects the display of built-in text in the system, but is not directly related to the switching of the front-end language site.
  2. Create independent language sites through the "Multi-site Management" feature.This is a language version that can be considered as an independent website instance, with its own domain name, data storage, and template configuration.languagesThe real source of label information. For example, you can setexample.comas the Chinese main station,en.example.comEnglish sub-sites, which are managed as two independent 'sites' in the AnQiCMS backend.

languagesThe label actually reads these site information defined in the "Multi-site Management" backend and extracts the language-related data from it, for use in the front-end template.This allows template developers to not delve deeply into the specific configuration details of the backend site, but to focus on how to display and make use of the existing language site data.

Summary

Although AnQiCMS'slanguagesThe tag has no parameters set, but that is precisely the cleverness of its design.It focuses on providing all configured multilingual site information, separating complex business logic from the frontend display.Developers only need to go through simpleforLoop to efficiently implement multi-language switching and SEO optimization and other key functions.This clear division of responsibilities ensures the simplicity of the system while also providing sufficient flexibility to meet the operational needs of multilingual websites.


Frequently Asked Questions (FAQ)

Q1: If I want to filter and only display certain languages (such as only displaying Chinese and English), how can I do it with AnQiCMS'slanguagestags?

A1: languagesThe tag itself does not provide filtering parameters. However, you can use the Go language template engine (similar to Django syntax) in the template.{% if %}Logic, while iterating.websitesWhen an array is making a conditional judgment. For example, only show Chinese and English:

{%- languages websites %}
    {%- for item in websites %}
        {% if item.Language == "zh-CN" or item.Language == "en-US" %}
            <a href="{{item.Link}}">{{item.LanguageName}}</a>
        {% endif %}
    {%- endfor %}
{%- endLanguages %}

By this method, you can according toitem.Language/item.LanguageNameor other fields for flexible filtering.

Q2:languagesWhat is the location configured in the AnQiCMS backend for obtaining the language site information tag?

A2:These language sites are mainly configured in the "Multi-Site Management" feature of the AnQiCMS backend.Each independent language site is created and managed as a "site", including its domain name, database information, administrator account, and the templates used.languagesThe label reads the information of sites marked with different languages among these configured and enabled sites.

Q3: How to enable multi-language functionality or add a new language site in the AnQiCMS backend?

A3:The feature of enabling multilingual function is not a simple switch, but is realized by configuring multiple independent sites.

  1. First, you can set the "default language package" in the "Background Settings" -> "Global Settings".This will affect the language of the system interface and built-in prompts.
  2. To add a switchable language site, you need to go to 'Multi-site Management'Then click "Add new site". Here, you need to configure a separate domain (or subdomain), database, and other relevant information for the new language version.When creating a site, there will be an option for you to specify the language of the site.Once created and configured,languagesThe tag can detect and display the new language site on the front end.

Related articles

How to use the `languages` tag to build a multi-language switch menu on the page?

AnQi CMS is committed to providing enterprises with efficient and flexible content management solutions, one of the core highlights being its powerful multilingual support capabilities.In today's globalized world, a website that can easily handle multilingual content undoubtedly provides strong support for a company to expand its international market and reach a wider user base.Today, let's delve into how Anqi CMS cleverly uses the `languages` tag to build a natural and smooth multilingual menu on your website, thereby opening a new chapter in global content marketing.

2025-11-06

What are the available return fields supported by the AnQiCMS multilingual site list tag?

In the powerful feature matrix of AnQiCMS (AnQiCMS), multi-language support is undoubtedly one of its highlights, helping businesses easily expand into the international market and bringing content directly to global users.In order to achieve this goal, it is crucial to flexibly use template tags.Today, let's delve into the `languages` tag used in AnQiCMS to retrieve the list of multilingual sites, see what valuable fields it can return to us, and how we can skillfully use these fields to build an excellent multilingual website.### Revealing the `languages` tag

2025-11-06

How to use the `languages` tag in AnQiCMS templates to display language options?

In today's globalized digital world, multilingual support for websites has become crucial for expanding markets and serving a diverse range of user groups.AnQiCMS (AnQiCMS) is well-versed in this field, deeply integrating multilingual functionality into its core architecture, committed to providing lightweight and efficient content management services to support the company's global layout.For website operators and template developers, understanding how to efficiently use the `languages` tag in AnQiCMS templates to display multilingual options is a required course for building internationalized websites.###

2025-11-06

How to get the list of all configured multilingual sites in AnQiCMS?

As an experienced website operations expert, I am well aware that having a website that supports multiple languages is crucial for businesses to expand their markets and enhance brand influence in today's global digital world.AnQiCMS (AnQi CMS) is an efficient and flexible content management system that provides excellent support in this regard.It can not only help us build multiple independent sites, but also allow these sites to easily switch between different languages, meeting the needs of global users.

2025-11-06

What is the type of the `websites` variable returned by the `languages` tag?

As an experienced website operations expert, I am well aware of the importance of multilingual support in building a global website.AnQiCMS (AnQi CMS) provides powerful and flexible multi-language content management capabilities, where the `languages` tag is the key tool to achieve this goal.Today, let's delve into the `languages` tag that returns the `websites` variable, what type it is, and how we can cleverly use it to build our multilingual site.### Unveiling

2025-11-06

How to iterate over the `languages` tag returned by the AnQiCMS template to list `websites`?

## Unlock the multilingual potential of AnQi CMS: How to efficiently traverse the `languages` tag returned by the `websites` list As an experienced website operations expert, I am well aware of the importance of multilingual websites in global marketing.AnQiCMS (AnQiCMS) relies on its powerful multi-site and multi-language support to provide a powerful tool for businesses and content operators to build internationalized websites.

2025-11-06

What is the role of the `LanguageName` field in the AnQiCMS multilingual site list?

In AnQiCMS, a system dedicated to providing efficient and customizable content management solutions, multilingual support is undoubtedly a core feature, especially crucial for enterprises targeting the global market or having audiences of different languages.When we delve into the multilingual site list of AnQiCMS, we will find that the `LanguageName` field plays a both intuitive and crucial role.

2025-11-06

What does the `Language` field represent in the AnQiCMS multilingual site list output?

## Unveiling the `Language` field in AnQiCMS multilingual sites: The 'identity' of international operation In AnQiCMS, an efficient and flexible enterprise-level content management system, multilingual support is one of its core highlights, aimed at helping businesses and content operators easily expand into international markets.When building and managing multilingual sites, we often encounter various fields related to language in templates or backend configurations.Among them, the `Language` field plays a crucial role in the output of the multilingual site list.

2025-11-06