In AnQi CMS multi-site management, efficiently sharing and calling data is the key to improving operational efficiency.Especially in the user system, sometimes we need to display or utilize user details from another site on a site, such as a unified user center, cross-site member privilege display, etc.This is provided by Anq CMSsiteIdParameters become a powerful bridge to connect user data across different sites.
Understand the core value of multi-site management.
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 an independent domain, content, template, and database configuration, which greatly reduces the complexity of managing multiple brands or business lines.However, this independence also brings challenges in certain scenarios, such as when a user registers 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, Anqi CMS provides a cross-site data call mechanism.It recognizes that, although the sites are independent, the operational logic and data requirements behind them are often interconnected. At this time,siteIdThe parameter has played 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.
siteIdThe parameter plays an important role in AnQi CMS, it can clearly specify which site we want to get data from. 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 lists(navListMultiple tags support throughsiteIdParameters to specify the data source. This means that once you have masteredsiteIdThe application allows you to be more flexible in data linkage 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 in the Anqi CMS backend, each site has a clear ID.
Focus on user data: how to utilizesiteIdCall user details
Now, let's focus on how to utilizesiteIdParameters to call user detail data across sites. Anqi CMS providesuserDetailTag, used specifically to retrieve detailed information about a specified user.
userDetailThe basic usage of the tag is to combineidparameters to specify the user's ID, then throughnameThe parameter retrieves specific user field information, 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 site A), you can do it like this:
{# 假设我们知道站点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 gositeIdWith2to the site, searchidWith10the user, and get theirUserNamefield.{% userDetail userProfile with id="10" siteId="2" %}Then it is to load all the available detail data of the user intouserProfilethis variable, and then you can go throughuserProfile.字段名to flexibly call. For example,userProfile.AvatarURLwill display the user's avatar link,userProfile.LastLoginthen it returns the user's last login timestamp,stampToDatethe filter can format it into a readable date and time.
It should be noted that,idThe parameter isuserDetailThe required parameter of the tag, it is used to specify the specific user.siteIdParameters are an optional supplement, when they are omitted, the system will default to fetching user data from the current site. Only when you really need to access user data from other sites do you need to explicitly provide itsiteId.
Application scenarios and precautions
UtilizesiteIdParameter cross-site call of user data, bringing great convenience and flexibility to the operation of your secure CMS multi-site.Imagine that you can display the VIP user list of all sub-brand sites (site B, site C, etc.) on a main brand's official website (site A);Or implement a unified member login module, after the user logs in, no matter which site is accessed, it can recognize the user's identity and display the corresponding personalized content.
Of course, when using this powerful feature, there are also some details to pay attention to:
- Performance considerationHowever, each call involves a database query, although cross-site calls are very convenient.If a large number of cross-site calls are made on a page, it may affect the page loading speed.Use it only when necessary and consider caching the call results appropriately.
- data permissionsEnsure that the data you call across sites is public or authorized.Although Anqi CMS has strict control over inter-site access in the background, it is still crucial to understand and comply with data privacy and security regulations from the operational level.
siteIdaccuracy: Be sure to confirm that you are usingsiteIdis the correct identifier of 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 flexible applicationsiteIdParameter, the multi-site management of AnQi CMS will become more efficient and intelligent, making your website ecosystem more closely connected and unified.
Frequently Asked Questions (FAQ)
1. Where can I see the details of each site?siteId?You can find the list of each created site in the "Multi-site Management" feature interface on the Anqi CMS backend. Each site entry usually clearly shows its corresponding uniquesiteId.
2. What data types can be utilized besides user details?siteIdHow to make cross-site calls with parameters?Of Security CMSsiteIdThe application scope of parameters is very wide, including but not limited to: document lists (archiveList), category details (categoryDetail), system configuration (system)、Contact Information(contactNavigation Menu (navList)and Friends Link(linkList) etc. Just as soon as you see it in the corresponding tag documentsiteIdYou can try to use it for cross-site calls once you see the parameter description.
3. Will cross-site data calls affect the performance of the website?Yes, cross-site data calls essentially increase the complexity of database queries.Although 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.Recommend that you weigh the pros and cons in actual use, prioritize caching data or reduce unnecessary cross-site queries to ensure **user experience**.