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

In the powerful feature matrix of AnQiCMS (AnQiCMS), multilingual support is undoubtedly one of its highlights. It helps enterprises easily expand into the international market and deliver 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 AnQiCMS used to obtain a list of multilingual siteslanguagesLabel, see how it can return some valuable fields for us, and how to cleverly use these fields to build an excellent multilingual website.

RevelationlanguagesLabel: Key to the multilingual site list

languagesThe tag is a special tool designed in AnQiCMS template engine to retrieve the list of all multi-language sites configured in the current system. Its usage is very simple and intuitive, no additional parameters are required, you just need to use it in the template by{% languages 变量名称 %}This form can be called. For example, you can name the returned data setwebsites, that is{% languages websites %}...{% endLanguages %}.

It is worth noting that,languagesthe tags returned bywebsitesIt is an array object, which means you need to useforLoop to traverse this collection, visit each multilingual site information one by one.In this way, you can easily provide users with language switching options, or implement more complex language logic on the backend website.

To deeply understand the available return fields

When we go throughforLoop throughwebsitesThis array represents eachitemindependent multilingual site. TheseitemContains a series of detailed fields, providing rich data support for building multilingual switching functions and optimizing SEO. Next, we will parse these core fields one by one:

  1. LanguageName(site language name)This field returns the language name of the current site, which is usually a friendly name visible on the user interface, such as “Simplified Chinese”, “English”, etc.You can directly use it for the display text of the language switch menu, making it clear to the user.

  2. Language(Language code) LanguageThe field provides international standard language codes such as "zh-CN", "en-US", etc. This code is crucial for technical implementation, especially in generatinghreflangThe tag plays an indispensable role in informing search engines of the corresponding relationship between different language versions of the page.At the same time, this code is also commonly used when performing language judgment or loading specific language resources in the back-end logic.

  3. LanguageEmoji(Language Emoji)If your design is lively or you want to save space,LanguageEmojiThe field will be your helpful assistant. It returns the Emoji icon corresponding to the language, such as Chinese.🇨🇳Or English.🇬🇧This provides another visual representation for the language switch button, making the interface more lively and interesting.

  4. LanguageIcon(Language Icon) LanguageIconThe field returns a URL address pointing to the icon file associated with the language, typically a flag icon. This is associated withLanguageEmojiSimilar, it provides high-quality graphic language identification, suitable for scenarios that require higher visual standards. If there is an icon, it will usually be used instead of Emoji.

  5. Name(Site Name)This field returns the specific name of a multilingual site, such as "AnQiCMS Chinese Site" or "AnQiCMS English Site". It may be moreLanguageNameInclude more specific site information, which can be used for more formal titles or descriptions.

  6. Link(Link address) LinkThe field is the core that connects different language versions. It returns the access URL address of the current multilingual site.When the user clicks the language switch button, this link will direct the user to the home page of the corresponding language version of the website or the corresponding language version of the current page (if the template logic supports it).

  7. Remark(Note) RemarkThe field is usually used to store additional information or notes that may not be directly displayed to users on the front end, but are valuable to website administrators or developers, such as special configuration instructions, internal codes, etc.In template development, if you need to display some custom site descriptions, you can also consider using this field.

  8. Nofollow(Nofollow tag) NofollowThe field is a boolean value (or an integer of 0/1), indicating whether the link to the multilingual site should be addedrel="nofollow"Properties. This is very important in SEO strategies, it can control whether the search engine tracks the link, and for some links that do not want to pass weight or only serve internal jumps, it can be set flexibly.

Application: Build multilingual switcher and SEO optimization

Understood these fields, we can start building practical functions.

Firstly, build an intuitiveLanguage switcheris the key to improving user experience. You can useLanguageNameto display text, combined withLanguageEmojiorLanguageIconProvide visual cues and useLinkfields to implement page redirection:

{%- languages websites %}
{%- if websites %}
<div class="language-switcher">
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}" class="lang-option">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}" class="lang-icon" />
        {%- else %}
        <span class="lang-emoji">{{item.LanguageEmoji}}</span>
        {% endif %}
        <span class="lang-name">{{item.LanguageName}}</span>
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

Secondly, for multilingual sites,hreflangTagIt is the most important thing in Search Engine Optimization (SEO). It helps search engines understand that your website provides pages in multiple languages or regions, so that the correct content can be displayed to users of different languages.You can useLinkandLanguagefield inheadgenerate these important metadata in the tags:

<head>
    {# 其他head内容 #}
    {%- languages websites %}
    {%- for item in websites %}
    <link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
    {%- endfor %}
    {%- endLanguages %}
</head>

Make good use oflanguagestags to enhance operational efficiency

languagesThe data provided by the tag is not just used for simple language switching, it is also a deep reflection of AnQiCMS in multi-site management and global content operations.By flexibly using these returned fields, you can not only build a complete, user-friendly multilingual interface, but also effectively optimize SEO to ensure that your content has good visibility in different language markets.This means higher operating efficiency, wider market coverage, and stronger competitiveness for small and medium-sized enterprises and self-media operators.

Frequently Asked Questions (FAQ)

Q1: WhylanguagesLabels do not support parameters like other list labelslimitororder?

A1:languagesThe design intention of the tag is to obtain all the multilingual sites that are configured in the current system.These sites are usually limited in number and are fixed system-level configurations, the order and quantity of which are often determined by the multi-site management backend, rather than dynamically adjusted by a single template call.Therefore, to keep it concise and focused on its core functions,languagesThe tag is designed not to accept additional filtering or sorting parameters. If you need to sort or filter the results on the frontend, you can do so after obtainingwebsitesthe array, using the template'sforloop andifJudge for secondary processing.

Q2: How can the current site being visited be determined in the template to highlight or apply specific styles?

A2: You can usesystemThe tag retrieves the language information of the current site and then compareslanguagesThe tag traverses outitem.LanguageAnd compares. AnQiCMS providessystemwhere{% system with name='Language' %}It will return the language code of the current site. CombinedlanguagesLabel, you can judge it like this: