What is the specific usage method of the `siteId` parameter in the `{% contact %}` tag?

In the powerful feature system of AnQiCMS, multi-site management is undoubtedly a highlight, allowing enterprises and operators to easily handle the complex needs of multiple brands, sub-sites, or content branches. And in our daily website template development and content operation,{% contact %}Labels are the powerful assistants we use to display website contact information. Today, as an experienced website operations expert, I will lead everyone to delve deeper{% contact %}A special and powerful parameter labeledsiteIdIt plays a key role in connecting contact information between different sites in a multi-site environment.


{% contact %}Label: Intuitive presentation of site contact information

Let's quickly review first{% contact %}The basic purpose of tags. In Anqi CMS,{% contact %}The label allows us to conveniently call various information configured in the "Contact Information Settings" on the backend, such as contact name, phone number, email, address, and even WeChat QR codes.This information can be system predefined, or can be customized according to our actual business needs.

For example, if we want to display the contact phone number of the current site in the template, we usually do it like this:

<span>联系电话:{% contact with name="Cellphone" %}</span>

Or, if we assign the contact phone number to a variable:

{% contact currentSitePhone with name="Cellphone" %}
<span>联系电话:{{ currentSitePhone }}</span>

This calling method is very intuitive, it will default to fetching and displaying the contact information of the site being visited.

siteIdParameter: The Secret Weapon of Cross-Site Data Calls

However, in the scenario of multi-site operations, we often encounter a need: to display on the page of a site,other sitescontact information.For example, you may have a main brand website (site A), under which there are several sub-brands (site B, site C), and you want to list the contact information of site B and site C on the "Contact Us" page of site A.{% contact %}The label cannot meet the needs.

This issiteIdThe time when parameters really shine.

siteIdThe parameter is{% contact %}An optional attribute of the label, its core function isTo specify the site ID of the data source.. Through forsiteIdAssign a specific site ID value so that we can clearly inform the AnQi CMS which site's contact information we want, rather than the information of the site being rendered on the current page.It effectively breaks the "locality" of data calls, achieving data sharing and integration across sites.

How to understandsiteIdWorking principle?

Imagine that your security CMS is like a headquarters, managing multiple independent websites (branches).Each department has its own contact information card.{% contact %}When labeling, the command center usually defaults to provide the business card of the current division (i.e., the current website). However, when you addsiteIdThe parameter specifies a particular department (for examplesiteId="2"When this is the case, the headquarters will accurately locate the department numbered 2 and pass its business card information to your template

siteIdThe specific usage of the parameter

In{% contact %}Introduce the tagsiteIdJust add the parameter after itsiteId="X"of whichXRepresents the ID of the target site you want to call the contact information. This ID is a unique identifier assigned by the Anqi CMS backend for each site.

1. Syntax structure:

{% contact 变量名称 with name="字段名称" siteId="目标站点ID" %}

Or, if you do not need to assign the result to a variable, output it directly:

{% contact with name="字段名称" siteId="目标站点ID" %}

2. Get the target site ID:You can view the detailed information of all the sites you have created in the "Multi-site Management" feature of the Anqi CMS backend.Each site will have a unique numeric ID.siteIdIs the correct number, otherwise it may not be able to obtain the data or obtain incorrect data.

3. Actual application example:

Assume that your main site ID is 1, and you also have a sub-brand site with ID 2. You want to display the contact phone number and WeChat QR code of the sub-brand site on the main site page.

  • Contact phone number for the sub-brand site:

    <p>
        子品牌站点联系电话:
        {% contact subBrandPhone with name="Cellphone" siteId="2" %}
        <span>{{ subBrandPhone }}</span>
    </p>
    
  • WeChat QR code for the sub-brand site:

    <p>
        子品牌站点微信二维码:
        {% contact subBrandQrcode with name="Qrcode" siteId="2" %}
        <img src="{{ subBrandQrcode }}" alt="子品牌微信二维码" style="width: 100px; height: 100px;">
    </p>
    

    In this way, even when you are in the template of the main site, you can flexibly display the contact information of other specific sites, greatly improving the reusability of the template and the efficiency of content management.

Cautionary notes and **practice

  • Define the goal:While usingsiteIdBefore, make sure you clearly specify which site's contact information you need to call, and ensure that you obtain the correctsiteId.
  • Default behavior:If you do not specifysiteIdparameter,{% contact %}The tag will always retrieve the contact information of the site currently being rendered.
  • Data consistency:When calling data across sites, please ensure that the target site has correctly configured the contact information you expect to obtain, otherwise the call result may be empty.
  • Scalability: siteIdThe parameter is not limited to{% contact %}Label, in many other template labels of Anqi CMS (such as{% system %}/{% archiveList %}/{% categoryList %}It also plays a similar role in specifying the data source site, which provides great convenience for multi-site content integration.
  • Performance consideration: Although the Go language developed CMS security performance is excellent, but excessive or complex cross-site data calls still need to be considered in the design to ensure website loading speed and user experience.

Summary

siteIdThe parameter is one of the important mechanisms for data sharing and integration in the multi-site management environment of AnQi CMS.It gives template developers great flexibility, allowing them to accurately call the required contact information from different sites according to business needs.siteIdThe usage will make your Anqi CMS multi-site operation more proficient, greatly enhancing the efficiency of content management and the value of template reuse.


Frequently Asked Questions (FAQ)

Q1:siteIdWhen must the parameter be used?A1:siteIdParameters are only needed when you want toaccess non-current websitescontact information data. If you only want to display the contact information of the current visited site, it is not necessary to add.siteIdparameter,{% contact %}The tag will default to retrieving the contact information of the current site.

Q2: How can you know the contact information of other sites?siteIdare?A2: You can log in to the Anqi CMS backend management interface, navigate to the 'Multi-site Management' feature.On this page, you will see a list of all sites created, and each site will usually display its unique numeric ID.siteId.

Q3:siteIdCan the parameter be used to call other tags (such as)systemorarchiveList) data?A3: Yes,siteIdThe parameter is also applicable to many other template tags in AnQi CMS. For example, you can usesiteIdto obtain the system configuration information of the specified site({% system with name="SiteName" siteId="X" %}Or call the article list of a specific site{% archiveList archives with type="list" siteId="X" %}This makes content aggregation and display in a multi-site environment very flexible.