In the multi-site management of Anqi CMS, efficiently sharing and accessing data is the key to improving operational efficiency.尤其是用户体系方面,有时我们需要在一个站点展示或利用另一个站点的用户详情,例如统一的用户中心、跨站点会员特权展示等。siteIdThe parameter has become a powerful bridge connecting user data between different sites.
Understand the core value of multi-site management.
The Anqi CMS stands out with its powerful multi-site management features, allowing us to easily create and independently operate multiple websites from a single backend.Each site can have independent domain names, content, templates, and database configurations, which greatly reduces the complexity of managing multiple brands or business lines.However, this independence also brings challenges in some scenarios, such as when users register on Site A, and Site B also needs to obtain their basic information for display or verification, the traditional independent management model seems inadequate.
To solve this problem, the Anqi CMS provides a cross-site data call mechanism.It recognizes that, although the sites are independent, the operating logic and data requirements behind them are often interconnected.siteIdThe parameter plays its role, it is like a map, guiding the system to where it needs to find the data you need.
siteIdParameter: the bridge for cross-site data calls
siteIdParameters play a crucial role in Aiqi CMS, they can clearly specify which site's data we want to obtain. This feature is not limited to user data, in fact, it includes document lists (archiveList), category details(categoryDetail)、System Settings(system)、contact information (contact)、navigation list (navList)等多个标签都支持通过siteId参数来指定数据来源。这意味着,一旦掌握了siteIdThe application of auto will enable you to be more flexible in linking data between multiple sites, breaking through information islands.
For cross-site calls, we need to know the unique identifier of the target site, which is itssiteIdThis ID is usually visible in the "Multi-site Management" list of the Anqi CMS backend, with each site having a clear ID.
Focus on user data: how to usesiteIdCall User Details
Now, let's focus on how to utilizesiteIdparameters to call user detail data across sites. Safe CMS providesuserDetailLabel, used specifically to retrieve detailed information about a specified user.
userDetailThe basic usage of the label is to combineidparameters to specify the user ID, and then throughnameParameters to get specific field information of the user, such as username, avatar, registration time, etc.
For example, if you want to display the name and avatar of a user (such as a special VIP user) with ID 10 from site B on a page of the current site (assuming it is site A), you can operate in this way:
{# 假设我们知道站点B的 siteId 是 2,并且要获取用户ID为 10 的信息 #}
{% userDetail otherUser with name="UserName" id="10" siteId="2" %}
<p>用户名称:{{ otherUser }}</p>
{% userDetail otherUserAvatar with name="AvatarURL" id="10" siteId="2" %}
<p>用户头像:<img src="{{ otherUserAvatar }}" alt="用户头像" /></p>
{# 或者,将所有信息一次性加载到变量中,再逐一取出 #}
{% userDetail userProfile with id="10" siteId="2" %}
<div>
<h3>{{ userProfile.UserName }}</h3>
<p>邮箱:{{ userProfile.Email }}</p>
<p>手机:{{ userProfile.Phone }}</p>
<img src="{{ userProfile.AvatarURL }}" alt="{{ userProfile.UserName }}的头像" />
<p>最近登录时间:{{ stampToDate(userProfile.LastLogin, "2006-01-02 15:04") }}</p>
</div>
In this example:
{% userDetail otherUser with name="UserName" id="10" siteId="2" %}This line of code indicates the system to gositeIdresponse for2to the site and searchidresponse for10for the user, and get theirUserNamefield.{% userDetail userProfile with id="10" siteId="2" %}If it is to load all the accessible details data of the useruserProfileinto this variable, and then you can access it viauserProfile.字段名to call flexibly. For example,userProfile.AvatarURLwill display the user's avatar link,userProfile.LastLoginthen returns the user's last login timestamp,stampToDatethe filter can format it into a readable date and time.
It is worth noting that,idParameter isuserDetailThe required parameter for the tag, it is used to specify the specific user.siteIdThe parameter is an optional supplement. When it is omitted, the system will default to retrieving user data from the current site. You only need to explicitly provide it when you actually need to access user data from other sites.siteId.
Application scenarios and precautions
UtilizesiteIdThe cross-site invocation of user data parameter brings great convenience and flexibility to your multi-site operation of Safe CMS.Imagine that you can display the VIP user list of all sub-brand sites (site B, site C, etc.) under a main brand official website (site A); or implement a unified member login module so that users can be identified and personalized content displayed after logging in, regardless of which site they visit.
Of course, when using this powerful feature, there are also some details that need to be paid attention to:
- Performance considerationsAlthough cross-site calls are very convenient, each call involves a database query.If there are a large number of cross-site calls on a page, it may have a certain impact on the page loading speed.Suggest using it only when necessary, and consider appropriate caching of the call results.
- Data permissionsPlease ensure that the data you call across sites is public or authorized.Although the Anqi CMS has strict control over inter-site access in the background, understanding and adhering to data privacy and security regulations is still crucial from the operational perspective.
siteIdaccuracy: Be sure to confirm that you are using:siteIdwhich is the correct identifier for the target site. IncorrectsiteIdThis will result in being unable to retrieve data or receiving incorrect data. In the "Multi-site Management" interface of the Anqi CMS backend, you can clearly see each site'ssiteId.
By using flexibilitysiteIdParameters, the multi-site management of Anqi CMS will become more efficient and intelligent, making your website ecosystem more close and unified.
Common Questions (FAQ)
1. Where can I see the information for each site?siteId?You can find the list of each created site in the "Multi-site Management" feature interface of the Anqi CMS backend. Each site entry usually clearly displays its corresponding uniquesiteId.
2. In addition to user details, what other data types can be used?siteIdParameters for cross-site calls?Anqi CMS'ssiteIdThe scope of parameter application is very wide, including but not limited to: document list (archiveList), category details(categoryDetail), system configuration (system)、contact information (contact)、Navigation Menu(navList)and Friends Links(linkList)etc. As long as you see the parameter description in the corresponding tag document,“siteIdyou can try to use it for cross-site calls.
3. Will it affect the website's performance when making cross-site data calls?Yes, cross-site data calls essentially increase the complexity of database queries.Although the AnQi CMS has considered performance optimization in its design, if a single page performs too many or too frequent cross-site calls, it may extend the page loading time.It is recommended that you weigh the pros and cons in actual use, prioritize caching data or reduce unnecessary cross-site queries to ensure a good user experience.