Good, as an experienced website operation expert, I am very willing to deeply analyze how AnQiCMS can efficiently and flexibly call the single-page detail data of other sites in a multi-site management environment.
Multi-site management of AnQi CMS: Easily handle cross-site single-page detail data call
In today's fast-changing digital world, many businesses and content operation teams face the challenge of managing multiple websites.In order to distinguish different product lines, service areas, or to expand the multilingual market, multi-site management has become a core requirement.AnQiCMS (AnQiCMS) emerged in such a context, with its powerful multi-site management capabilities, it helps us easily manage multiple content platforms from a single backend.
However, multi-site operation is not just about simply creating and managing multiple independent websites.The true value lies in achieving collaboration and data sharing between sites, avoiding duplication of construction, and improving overall operational efficiency.Today, let's delve into a very practical feature in a multi-site environment: how to cleverly call the single-page detail data of other secure CMS sites on the page of your current site.
Core advantages of AnQi CMS multi-site management
First, let's quickly review the convenience brought by the AnQi CMS multi-site management.It allows you to create and maintain multiple independent website instances in the same system backend.Each site can have its own domain, content, template, and database configuration, but all of these are centralized in one management interface.This centralized management not only greatly reduces our daily maintenance workload, but more importantly, it lays a solid foundation for cross-site data sharing and resource integration.
For example, a group company may own multiple sub-brand websites, each with an independent "About Us" page.If the headquarters website needs to aggregate and display the profiles of all sub-brands, or if a regional site wants to refer to the unified "Privacy Policy" page released by the headquarters, manually copying and pasting is obviously inefficient and prone to errors.At this point, the cross-site call capability of AnQi CMS is particularly important.
Core operation: throughsiteIdParameter call single-page data of other sites
In the AnQi CMS template system, we have a rich set of tags to obtain various types of content data. For single-page (Page) details, we mainly use the tag: pageDetailThe tag is typically used to retrieve the single-page content of the current site, but its real strength lies in the fact that it is built in with asiteIdThe parameter, it is this parameter, that打通了cross-site data call.
When you want to call a single-page content of another secure CMS site on the current site, what you need to do is explicitly tellpageDetailLabel, the data you want is from which site. The identifier for 'which site' issiteId.
Step 1: Determine the target site.siteId
While usingsiteIdBefore the parameter, we first need to know the unique identifier ID of the target site. ThissiteIdIs a number, usually found in the "Multi-site Management" feature in your Anqin CMS backend.Each site successfully created will have a unique ID assigned to it.Please log in to the backend of your main site, navigate to the "Multi-site Management" page, where you will see a list of all configured sites, and easily find the corresponding numeric ID for each site.For example, your primary site may be an ID1, a sub-brand website may be ID2, another regional site may be ID3and so on.
Second step: applypageDetailCall cross-site tagging
Obtain the target sitesiteIdAfter that, we can flexibly use it in the template of the current sitepageDetailTag to call single-page data from other sites.pageDetailTags can be used to specify the single page itself,id(i.e., single page ID) or,token(URL alias) now you can also pass in,siteIdto specify the data source.
Let's look at a specific code example. Suppose you want to display the ID of2in the sub-brand website of10in the "About Us" single page content:
{# 假设您要调用站点ID为2的子品牌网站中,ID为10的“关于我们”页面数据 #}
{% pageDetail otherSiteAboutUs with id="10" siteId="2" %}
{% if otherSiteAboutUs %}
<div class="card p-4 mb-4">
<h2 class="h4 mb-3">来自子品牌站点的“{{ otherSiteAboutUs.Title }}”</h2>
<div class="content mb-3">
{# 调用并安全输出单页内容,注意使用 |safe 过滤器防止HTML被转义 #}
{{ otherSiteAboutUs.Content|safe }}
</div>
<p class="text-muted small">
了解更多请访问:<a href="{{ otherSiteAboutUs.Link }}" target="_blank" rel="noopener noreferrer">{{ otherSiteAboutUs.Title }}</a>
</p>
</div>
{% else %}
<p class="alert alert-warning">未找到指定子品牌站点的单页数据。</p>
{% endif %}
{% endpageDetail %}
In this code block:
{% pageDetail otherSiteAboutUs with id="10" siteId="2" %}We define a variable namedotherSiteAboutUsThe variable is used to store the single-page data obtained.id="10"Specified the ID of the target single page, whereassiteId="2"then clarified that the data should be obtained from the site with ID 2.{% if otherSiteAboutUs %}This is a good programming habit, used to check if the data is successfully obtained, to avoid page errors.{{ otherSiteAboutUs.Title }}/{{ otherSiteAboutUs.Content|safe }}/{{ otherSiteAboutUs.Link }}These are commonly used fields for calling the single-page detail data. You can access various properties of the single-page by using the dot operator.such as title (Title), content (Content), link (Link), description (Description),and thumbnail (LogoorThumb) and so on.|safe: It is especially important to note that when you call the rich text editor to edit theContentbe sure to use|safeFilter. This tells the template engine that the content is safe HTML code and should be rendered directly without escaping, thus avoiding displaying the HTML tags of the original content.
In this way, you can call the single-page detail data of other sites as needed at any template position on the current site, realizing efficient reuse and aggregation display of content.
Consideration of practical application scenarios
This cross-domain calling mechanism is very practical in many scenarios:
- Unified brand information displayIf you have multiple sub-brand websites, the main brand website can call the "brand story" or "contact information" single page of each sub-brand to form a unified corporate overview.
- Global content synchronizationFor enterprises with multilingual sites, the main language site can publish core pages such as the "Terms of Service" or "Privacy Policy", and then other language sites can go through
siteIdDirectly call these multilingual single pages to ensure consistency of content and facilitate centralized updates. - Content aggregation portalIn news portals or industry websites, the main site can aggregate and display feature pages from different thematic sub-sites (such as "Industry Overview", "Expert Interview"), enriching the content of the main site.
Beyond Single Page: AnQiCMS's General Cross-Site Call Ability
It is worth mentioning that the Anqi CMSsiteIdThe parameter is notpageDetailTag exclusive. It is a general cross-site call mechanism, almost贯穿于all the tags for obtaining content, such as:
archiveDetailandarchiveListUsed to call the article or product details and list data of other sites.categoryDetailandcategoryListUsed to get the category details and category list of other sites.systemandcontact: Even can get system configuration information from other sites such as