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

In the powerful feature matrix of AnQiCMS, multilingual support is undoubtedly one of its highlights, helping enterprises easily expand into international markets and deliver content directly to global users.To achieve this goal, it is crucial to flexibly use template tags.languagesTags, see what valuable fields it can return for us, and how to cleverly use these fields to build an excellent multilingual website.

UnveilinglanguagesTag: The key to the list of multilingual sites

languagesTags are a powerful tool specially designed in AnQiCMS template engine to retrieve the list of all configured multi-language sites in the current system. Its usage is very simple and intuitive, requiring no additional parameters. You just need to use it in the template by{% languages 变量名称 %}This form can be used to call. For example, you can name the data set returned.websites, which is{% languages websites %}...{% endLanguages %}.

It is worth noting that,languagesTag returnswebsitesis an array object, which means you need to use.forTranslate this collection by looping through it and accessing the information of each multilingual site one by one.In this way, you can easily provide users with language switching options, or implement more complex language logic on the backend of the website.

a deep understanding of the available return fields.

When we go throughforto iteratewebsitesThis array indicates that eachitemrepresents an independent multilingual site.itemIt contains a series of detailed fields, providing rich data support for us to build multilingual switching functions and optimize 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 in the language switch menu, making it clear to the user.

  2. Language(language code) LanguageThis field provides language codes that comply with international standards, such as “zh-CN”, “en-US”, etc. This code is crucial for technical implementation, especially in generatinghreflangTags play an indispensable role in informing search engines of the corresponding relationship between different language versions of pages.At the same time, this code is also commonly used when performing language judgment or loading specific language resources on the backend.

  3. LanguageEmoji(Language Emoji)If your design is lively or you want to save space,LanguageEmojiFields will be your good helper. It returns the corresponding Emoji icon for the language, such as for Chinese.🇨🇳Or English.🇬🇧This provides another visual representation of 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 equivalent toLanguageEmojiSimilar, providing high-quality graphical language labels, suitable for scenes that require higher visual standards. If there is an icon, it will usually be used instead of an Emoji.

  5. Name(Site Name)This field returns the specific name of the multilingual site, such as “AnQiCMS Chinese Site” or “AnQiCMS English Site”. It may beLanguageNameInclude more specific site information that 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 current multi-language site's access URL.When the user clicks the language switch button, this link will direct the user to the home page or the corresponding language version of the current page (if the template logic supports it).

  7. Remark(Note) RemarkThe field is typically used to store some additional information or notes, which may not be directly displayed to the users on the front-end, but can be of reference value 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), used to indicate whether the link of this multilingual site should be addedrel="nofollow"Property.This is very important in SEO strategy, it can control whether the search engine tracks the link, and it can be flexibly set for links that do not want to pass on weight or are used only for internal redirection.

Actual Application: Building multilingual switchers and SEO optimization

Understood these fields, and we can start building practical functions.

First, build an intuitiveLanguage Switcheris the key to enhancing user experience. You can useLanguageNameto display text, combined withLanguageEmojiorLanguageIconProvide visual cues and useLinkfields to implement page navigation:

{%- 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,hreflangtagsIt is the most important aspect of Search Engine Optimization (SEO).It helps search engines understand that your website provides pages in multiple languages or regions, thus displaying the correct content to users of different languages.LinkandLanguageis inheadgenerate these important metadata tags:

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

Use wiselylanguagestags to improve operational efficiency

languagesThe data provided by the label is not just for simple language switching, it is also a deep reflection of AnQiCMS in multi-site management and global content operation.By flexibly using these returned fields, you can not only build a fully functional and user-friendly multilingual interface, but also effectively carry out SEO optimization to ensure that your content achieves good visibility in different language markets.This means higher operational efficiency, broader market coverage, and stronger competitiveness for small and medium-sized enterprises and self-media operators.

Common Questions and Answers (FAQ)

Q1: WhylanguagesTags do not support other list tags likelimitororderparameters?

A1:languagesThe original design intention of the label is to obtain all the multilingual sites that are currently configured in the system.These sites are usually limited in number and are system-level fixed configurations, and their order and quantity are often determined by the background multi-site management rather than dynamically adjusted by a single template call.languagesLabels are designed to accept no additional filtering or sorting parameters. If you need to sort or filter the results on the frontend, you can use the template afterwebsitesreceiving the array,forloop andif【en】Determine the site language for secondary processing.

【en】Q2: How can you determine the current visited site's language in a template to highlight or apply specific styles?

【en】A2: You can throughsystemLabel gets the language information of the current site and then compares it withlanguagesLabel traverses out theitem.LanguageCompare. AnQiCMS provides asystemtag for each language site,{% system with name='Language' %}It will return the language code of the current site. Combined withlanguagesLabel, you can judge like this: