How to test the `siteId` parameter to correctly identify and call data in the multi-site contact information tag?

Calendar 👁️ 72

AnQi CMS is a powerful enterprise-level content management system, and its multi-site management capabilities undoubtedly provide great convenience and flexibility for operators.How to ensure that each site can accurately call its exclusive information when managing multiple brands or sub-sites, especially for critical data such as contact information, is particularly important.Today, let's delve into how to test and verify in a multi-site environment.siteIdWhether the identification of parameters in the contact information tag and data call is correct.

Get to knowsiteIdThe role in a multi-site environment.

The AnQi CMS allows multiple sites to share a core system, each site has an independent configuration, content, and management backend. To distinguish the data of these sites, the system assigns a unique identifier to each site, namelysiteId. When you need to fetch data from *non-current access site* in the template,siteIdit becomes the key to indicating the data source.

For example, a company may have a main site and sub-brand sites, which are managed under the same AnQiCMS system. The contact phone number of the main site is123456789, and the contact phone number of the sub-brand site is987654321. In the main station template, if I want to display the contact phone number of the sub-brand station instead of just the main station's phone number, then it is necessary tositeId.

contactThe tag is a powerful tool in Anqi CMS used to obtain various information from the "Contact Information Settings" backend, such as contacts, phone numbers, addresses, email, WeChat, etc. By default, if not specifiedsiteIdIt will automatically call the contact information of the site being visited. However, in the scenario of cross-site data calls,siteIdprecise use is indispensable.

Prepare the test environment: Build distinguishable multi-sites

To effectively testsiteIdFirstly, we need a clear multi-site environment.

  1. Set up at least two sites:Make sure your secure CMS system is configured with at least two independent sites.You can refer to the Anqicms documentation, such as the "Anqicms Docker installation tutorial using Baota" or the "Anqicms multi-site tutorial adding through reverse proxy", to complete this step.
  2. Configure unique contact information:This is a testsiteIdWhether the key is recognized correctly.
    • Log in to the backend of the first site (we call it "Site A"), enter "Backend Settings" -> "Contact Settings".}Set the contact phone number to a clear and identifiable value, such as 'Site A dedicated phone: 111-1111-1111'.
    • Similarly, log in to the backend of the second site ("Site B") and enter "Backend Settings" -> "Contact Information Settings".Set the contact phone number to a completely different, clearly identifiable value, such as 'Site B dedicated phone: 222-2222-2222'.
  3. Get the site.siteId:In the Anqi CMS backend, you can usually find the unique for each site in the "Multi-site Management" list, or when viewing the configuration details of each site.siteIdAssuming site A'ssiteIdIs1, Site B'ssiteIdIs2. Please remember these IDs, they will be used for template calls.

Perform a test: Call contact information of different sites in the template

Now, we will write code in the template to verifysiteIdthe effect. For convenience of testing and comparison, we can choose a common template file, such asbash.html(This usually contains header or footer information that loads on all pages), or create a dedicated test page template.

Assuming we choose to add test code on a certain page,<body>inside:

{# 假设我们正在访问站点A(siteId=1) #}

<h3>联系方式数据调用测试 - 当前站点A</h3>

{# 1. 不指定siteId:默认应显示当前站点(站点A)的联系电话 #}
<p>
    <strong>当前站点默认电话:</strong>
    {% contact with name="Cellphone" %}
</p>

{# 2. 明确指定siteId为站点A的联系电话 #}
<p>
    <strong>明确指定站点A电话(siteId=1):</strong>
    {% contact siteA_phone with name="Cellphone" siteId="1" %}{{ siteA_phone }}
</p>

{# 3. 明确指定siteId为站点B的联系电话 #}
<p>
    <strong>明确指定站点B电话(siteId=2):</strong>
    {% contact siteB_phone with name="Cellphone" siteId="2" %}{{ siteB_phone }}
</p>

<hr>

{# 假设我们现在模拟访问站点B(siteId=2) #}

<h3>联系方式数据调用测试 - 当前站点B (仅供理解,实际需访问站点B URL)</h3>

{# 以下代码在实际访问站点B时才会生效 #}
{# 1. 不指定siteId:默认应显示当前站点(站点B)的联系电话 #}
<p>
    <strong>当前站点默认电话(访问站点B时):</strong>
    {% contact with name="Cellphone" %}
</p>

{# 2. 明确指定siteId为站点A的联系电话 #}
<p>
    <strong>明确指定站点A电话(siteId=1,访问站点B时):</strong>
    {% contact siteA_phone_on_B with name="Cellphone" siteId="1" %}{{ siteA_phone_on_B }}
</p>

{# 3. 明确指定siteId为站点B的联系电话 #}
<p>
    <strong>明确指定站点B电话(siteId=2,访问站点B时):</strong>
    {% contact siteB_phone_on_B with name="Cellphone" siteId="2" %}{{ siteB_phone_on_B }}
</p>

Please note that the second section of the test code for "current site B" is to help you understand the expected result, in fact, you only need to deploy the first section of the code to your public template, and then visit the front-end pages of sites A and B for verification.

Check the data call for correctness

  1. Access the frontend page of site A:

    • Observe the value displayed at the
    • Observe the value displayed at
    • Observe the value displayed at “Specified site B phone (siteId=2)”, it should be consistent with the “Site B dedicated phone: 222-2222-2222” set in the site B backend.
  2. Visit the front page of site B:

    • Observe the value displayed at "Current site default phone", it should be consistent with the "Site B dedicated phone: 222-2222-2222" you set in the Site B backend.
    • Observe the value displayed at

Related articles

What are the common configuration mistakes between AnQiCMS contact information settings and the `contact` tag call?

## Common Misconfigurations in Setting up AnQi CMS Contact Information: Make Your Contact Information Clear and Visible Displaying contact information clearly and effectively in website operations is a key step in building user trust, promoting communication, and transforming business. AnQiCMS provides a convenient backend setting and template tag, allowing you to easily manage and call these key information.However, even such convenient features are often hindered by seemingly minor configuration mistakes, resulting in contact information not displaying properly on the front page, causing confusion for operators

2025-11-06

After updating the contact information on the AnQiCMS backend, why didn't the front end take effect immediately?

Hello! As an experienced website operation expert, I fully understand the confusion and anxiety you may feel when you find that the front-end does not take effect immediately after updating the AnQiCMS backend settings.This is a very common phenomenon in website operation, usually not a system failure, but a mechanism designed to improve website performance and user experience is at work.Today, let's delve into the possible reasons behind this and provide a detailed solution.### AnQiCMS Back-end contact information update, why does the front-end not take effect immediately

2025-11-06

Why did I use the `{% contact %}` tag in the AnQiCMS template but the content did not display on the front end?

As an experienced website operations expert, I know that even a small template tag problem may confuse and anxiety the operator while managing and maintaining a website.Today, let's delve into a problem that AnQiCMS (AnQi CMS) users occasionally encounter: when the `{% contact %}` tag is used in the template, no content is displayed on the front page.Don't worry, this is usually not a big problem. Just follow the steps to investigate, and we can find the cause and solve it soon.

2025-11-06

How to use AnQiCMS's `{% system %}` tag and `{% contact %}` tag to combine and display the global contact information of the website?

As an experienced website operations expert, I know that effectively and uniformly managing website content is the foundation of success in an increasingly complex network environment.AnQiCMS (AnQiCMS) leverages the efficient and flexible customization capabilities of the Go language to provide us with many conveniences.Today, let's delve deeply into two seemingly simple but extremely powerful tags in Anqi CMS - `{% system %}` and `{% contact %}`, as well as how to skillfully combine them to build a unified and easy-to-maintain website global contact information display system

2025-11-06

Can AnQiCMS's anti-crawling feature effectively protect contact information from malicious crawlers?

Certainly, as an experienced website operation expert, I am more than happy to delve into the anti-crawling function of AnQiCMS and explain in detail how it effectively protects your website contact information. --- ## AnQiCMS anti-crawling function: Build a solid barrier for your contact information In today's digital age, information collection has become a norm, but the harvesting of website contact information by malicious crawlers has brought many troubles to enterprises, such as spam emails, harassment calls, and so on.

2025-11-06

How to ensure that the contact label output content of AnQiCMS is SEO-friendly?

AnQi CMS is a content management system tailored for small and medium-sized enterprises and content operation teams, which has integrated the concept of search engine optimization from the very beginning.In website operation, contact information is not only a bridge for communication between users and us, but also an important signal for search engines to understand our business and confirm our authenticity.Therefore, how to ensure that the content output by the AnQiCMS contact information tag is SEO-friendly is a key point that every website operator should pay attention to.##

2025-11-06

Does AnQiCMS contact information label support automatic switching to display corresponding language contact information based on the user's visited language?

## Contact information label for AnQiCMS: How to switch display intelligently under multilingual environments?In today's global business environment, multilingual support for websites is no longer an option, but a necessity for businesses to expand into international markets.For enterprises that use content management systems (CMS) to build and manage websites, how to efficiently handle multilingual content, especially for key information such as contact details, is a common concern for operators.AnQiCMS (AnQiCMS) is a system focused on providing enterprise-level content management solutions

2025-11-06

What convenient operations does AnQiCMS provide if the website needs to update contact information in bulk after a redesign?

The website overhaul is an important step to improve user experience and brand image, however, the data update work that comes with it is often headache-inducing, especially when it comes to batch modifying the contact information that can be found everywhere on the website.For users of AnQiCMS, fortunately, this system took full consideration of operational efficiency from the very beginning, providing a series of convenient operations to make this task exceptionally easy.When talking about contact information on a website, it usually includes phone number, email, address, social media links, and so on.

2025-11-06