In AnQiCMS's multi-site environment, data intercommunication is a key factor in improving operational efficiency and achieving content integration.Sometimes, we may need to display the content of child sites on the main site, or call the contact information of another brand site within a business site.siteIdThe parameter is particularly important, as it helps us easily implement cross-site data calls and display.
Understanding the multi-site advantages of AnQiCMS
AnQiCMS was designed with the need for multi-site management in mind, allowing users to create and independently manage multiple sites. Each site has its own content, templates, and configurations, but they share a single backend management system.This architecture not only reduces redundant work, but also provides convenience for data sharing and resource integration.Each site created independently is assigned a unique digital ID by the system, which is the 'identity card' for cross-site data calls.
Core Mechanism:siteIdThe application of parameters
siteIdThe parameter is a general attribute of AnQiCMS template tags, whose core function is to clearly inform the system: 'I need to get data from which site'. When you do not specifysiteIdWhen, the template tag will default to retrieving data from the current visited site. And once you specify another site's ID, the system will redirect to that site's data source for queries.siteIdSpecified another site's ID, the system will redirect to that site's data source for queries.
How do you know the target site?siteIdWhat?It is very simple, just log in to the AnQiCMS backend management interface and go to the 'Multi-site Management' function.Here, you will see a list of all sites created, each with a clear numeric ID.Remember the ID of the target site you want to call data from, and you can use it in the template next.
Flexible practice: Calling data from other sites in the template
siteIdParameters are widely used in various data call tags of AnQiCMS, such asarchiveList(Document List),archiveDetail(Document Details),categoryList(category list),pageDetail(Single Page Details)、system(System Settings) andcontact(Contact Information) etc. Below, we will look at its usage through several common scenarios:
场景一:In the main station, display the latest article list of the sub-station
Assume your main site ID is 1, and you have a sub-site ID of 2. You want to display the latest 5 articles of the sub-site in a module of the main site. You can write it like this in the main site's template file:
{% archiveList subSiteArchives with siteId="2" limit="5" %}
{% for item in subSiteArchives %}
<div class="article-item">
<a href="{{ item.Link }}">
<h3>{{ item.Title }}</h3>
<p>{{ item.Description|truncatechars:100 }}</p>
</a>
</div>
{% empty %}
<p>当前子站没有最新文章。</p>
{% endfor %}
{% endarchiveList %}
Here,siteId="2"Explicitly instruct the system to retrieve article data from the child station with ID 2. Through the loopsubSiteArchives, we can then display the titles, links, and summaries of these articles on the main site.
Scene two: Get specific category information from other sites
If you want to display the name and link of a specific product category (category ID 10) from a product showcase site (ID 3) on a page of a comprehensive portal (ID 1), you can do it like this:
{% categoryDetail productCategory with name="Title" id="10" siteId="3" %}
<p>产品站的分类名称:<a href="{% categoryDetail with name='Link' id='10' siteId='3' %}">{{ productCategory }}</a></p>
在这个例子中,我们通过id="10"andsiteId="3"共同精确地定位到了目标站点的特定分类,并成功获取了它的标题。
场景三:统一显示主站的联系方式
In multi-site management, different sites may sometimes need to display the same company's unified contact information, such as the main site's (ID 1) phone number. You can call the main site's contact phone number like this in the footer or contact page template of all sub-sites:
<p>统一联系电话:{% contact with name="Cellphone" siteId="1" %}</p>
So, no matter which child site, the contact phone number configured by the main site will be displayed, which is convenient for unified management and update. Similarly,systemtags can also besiteIdCall the website name, Logo, and other general configurations of other sites.
Expansion of practical application scenarios
siteIdFlexible use of parameters, bringing infinite possibilities for multi-site content operation:
- Content aggregation of the group's official website:The main group website can aggregate and display the latest news, product updates, or event previews of its affiliated subsidiaries websites.
- Cross-brand marketing:A marketing page of a brand, which can cleverly introduce the product list of a sibling brand or user reviews, thus enhancing the richness of the product line.
- Complementary multilingual sites:If you have multiple language sites, such as English sites and Chinese sites, you can make use of
siteIdRefer to specific content of another site on one of the sites to increase the coverage of the content. - Unified resource display:Centralize management of certain public resources, such as unified FAQ pages, terms of use, or about us pages, and through
siteIdinvocations.
Points to consider when using
When usingsiteIdWhen making cross-site data calls, there are several points to note:
siteIdaccuracy:Make sure that you are using:siteIdIt is correct, an incorrect ID will cause the data to be unable to be retrieved or to retrieve unexpected content.- Performance optimization:Although AnQiCMS is developed in Go language and performs well, it is still recommended to pay attention to the page loading speed when making a large number of complex cross-site data calls on a single page.The planning of call quantity and caching strategy can further optimize the user experience.
- SEO and content duplication:If you use large amounts of complete articles or content blocks from other sites on a site, search engines may consider it duplicate content. When designing cross-site content strategies, consider the uniqueness and value of the content, or use them appropriately.
rel="canonical"Label to indicate the original source of content, to avoid unnecessary SEO risks.
AnQiCMSsiteIdThe parameter is a powerful and practical tool in multi-site operation, which achieves data interconnection between sites in a simple and intuitive way, making your content management more flexible and efficient.
Common Questions (FAQ)
Q1: How to find a site?siteId?
A1: Log in to the AnQiCMS backend management interface, click the "Multi-site Management" feature in the left menu. In the displayed list of sites, you will see that each site is paired with a unique digital ID, which is what you need to use in the templatesiteId.
Q2: Can I call data from multiple different sites on the same page?
A2: Of course. You just need to specify each one separately in different data call tags.siteIdauto. For example, you can display the latest articles of site A and the recommended products of site B on the same page, just make sure each tag issiteIdauto. The parameter settings are correct.
Q3: Frequent usesiteIdWill calling data from other sites affect website performance and SEO?
A3: A small amount of reasonable cross-site data calls usually have little impact on website performance, and AnQiCMS's high concurrency architecture can support it well.But when performing a large or complex cross-site query, it may still increase the server burden.Suggest optimizing the query logic during design.For SEO, if a large number of other sites' full content is cited, it may be regarded as duplicate content by search engines.rel="canonical"The tag clearly specifies the original source of the content, guiding search engines to index correctly.