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