In the multi-site environment of AnQiCMS, data interoperability is a key factor in improving operational efficiency and integrating content.Sometimes, we may need to display the content of a sub-site on the main site, or call the contact information of another brand site in a business site.At this time, AnQiCMS providessiteIdParameters are particularly important, as they can help us easily implement cross-site data calls and display.
Understand the multi-site advantages of AnQiCMS.
AnQiCMS was designed from the beginning to consider the need for multi-site management, allowing users to create and independently manage multiple sites, each with its own content, templates, and configurations, but they share a single back-end 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 numeric ID by the system, which is the "identity card" we use for cross-site data calls.
Core mechanism:siteIdParameter usage
siteIdThe parameter is a universal 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 specifysiteIdAt that time, the template tag will default to retrieving data from the currently visited site. And once you go throughsiteIdspecified another site's ID, the system will redirect to the data source of that site for querying.
How can you know the target site?siteIdIt's simple, just log in to the AnQiCMS backend management interface and go to the 'Multi-site Management' feature.Here, you will see a list of all sites created, each site will have a clear numeric ID.Remember the ID of the target site you want to call the data from, and then you can use it in the template.
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) and so on. Below, we will go through several common scenarios to see how it is used:
Scenario one: Displaying the latest article list of the sub-site on the main site.
Assuming your main site ID is 1 and you have a sub-site ID of 2, you want to display the latest 5 articles from the sub-site in a module on the main site. You can write it in the main site's template file like this:
{% 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 station.
Scenario two: Retrieve 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>
In this example, we go throughid="10"andsiteId="3"Accurately located the specific category of the target site and successfully obtained its title.
Scenario three: Display the main site's contact information uniformly.
In multi-site management, different sites may need to display the same company's unified contact information, such as the main site (ID 1) phone number. You can call the main site's contact number like this in the footer or contact page template of all sub-sites:
<p>统一联系电话:{% contact with name="Cellphone" siteId="1" %}</p>
This way, no matter which child site, it will display the contact phone number configured by the main site, convenient for unified management and update. Similarly,systemTags can also be used throughsiteIdCall the website name, Logo and other common configurations of other sites.
Expansion of practical application scenarios
siteIdFlexible use of parameters, bringing endless possibilities for multi-site content operation:
- Content aggregation of the group's official website:The main station can summarize and display the latest news, product updates, or event previews of its subsidiary company websites.
- Cross-brand marketing:A marketing page for a brand, which can cleverly introduce the product list of sibling brands or user reviews, thereby enriching the product line.
- Complementary multilingual sites:If you have multiple language sites, such as English and Chinese sites, you can take advantage 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 make them available across all related sites.
siteIdCall.
Points to consider when using
While usingsiteIdWhen making cross-site data calls, there are several points to note:
siteIdAccuracy:Make sure you use: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 based on Go language and performs well in terms of performance, it is still recommended to pay attention to the loading speed of the page when making a large number of complex cross-site data calls on a single page.A well-planned number of calls and caching strategy can further optimize user experience.
- SEO and content duplication: If you use a lot of full articles or content blocks from other sites on a site, search engines may consider it duplicate content. When designing cross-site content strategy, consider the uniqueness and value of the content, or use it appropriately.
rel="canonical"Label to indicate the original source of the content to avoid unnecessary SEO risks.
AnQiCMS'siteIdThe parameter is a powerful and practical tool in multi-site operation, which achieves interconnection of data between sites in a simple and intuitive way, making your content management more flexible and efficient.
Frequently Asked Questions (FAQ)
Q1: How to find a site'ssiteId?
A1: Log in to the AnQiCMS backend management interface, click the 'Multi-site Management' function in the left menu. In the displayed site list, you will see that each site is paired with a unique numeric ID, which is what you need to use in the template.siteId.
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.siteIdit is possible. For example, you can display the latest articles from site A and the recommended products from site B on a single page, just make sure that each tagsiteIdis set correctly.
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, the high concurrency architecture of AnQiCMS can well support it.But when performing a large or complex cross-site query, it may still increase the server load.It is recommended to optimize the query logic during design. For SEO, if a large amount of complete content from other sites is referenced, it may be considered duplicate content by search engines.To avoid this problem, it is recommended to ensure that the referenced content has enough uniqueness, or userel="canonical"Tags clearly specify the original source of the content, guiding search engines to correctly index.