How to call data from other sites in a multi-site environment using the siteId parameter?

Calendar 👁️ 80

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 ofsiteIdRefer 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:

  1. 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.
  2. 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.
  3. 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.

Related articles

How to debug variable content and type in AnQiCMS template (using dump filter)?

When using AnQiCMS to build websites and customize templates, we often encounter situations where the content displayed on the page is not as expected, or it seems that a variable is not passing correctly.At this moment, it is particularly important to be able to quickly view the actual content and data type of variables in the template.Fortunately, AnQiCMS's template engine (which adopts a syntax similar to Django) provides us with a very practical tool—the `dump` filter, which helps us easily reveal the mysteries of variables.### Core Function: `dump`

2025-11-08

How to implement pagination display and like function for comment content in AnQiCMS?

In website operation, user comments and interaction are the key to enhancing the vitality of content.AnQiCMS (AnQiCMS) provides powerful content management capabilities, among which the comment feature is an important bridge for user interaction with content.This article will discuss in detail how to implement pagination for comment lists in Anqi CMS, as well as add a like function for comment content, enhancing the interactive experience of your website to a higher level.### CMS Review Function Overview The CMS has built-in article comment and comment management functions from the early version, which provides native user interaction support for the website

2025-11-08

How to enable anti-crawling interference code and image watermark in AnQiCMS to protect the display of content?

In today's era of increasingly rich digital content, protecting original content on websites is particularly important.AnQiCMS (AnQiCMS) understands the pain points of content creators and corporate users, and has specifically built anti-crawling interference codes and image watermarking functions to help users effectively prevent their content from being maliciously scraped and stolen, while also strengthening brand identity.### Protect content security: Enable anti-capture interference code The value of original content is self-evident, but information collection tools on the Internet may copy your articles in large quantities without permission, which not only harms the rights and interests of the original creators but may also divert website traffic

2025-11-08

How to safely parse a URL string into a clickable a tag in AnQiCMS template?

In website content operation, we often need to display some website URLs, email addresses, and other information in articles, introductions, or custom fields.If this information is just plain text, users cannot click to jump directly, which not only affects the user experience but may also reduce the interactivity of the content and the SEO friendliness of the website.Convert these URL strings securely and intelligently into clickable `<a>` tags, which is a very practical feature in the AnQiCMS template.AnQiCMS as an enterprise-level content management system has fully considered the flexibility and security of content display from the beginning of its design

2025-11-08

How to traverse an array and control display style with loop tags (for) in AnQiCMS templates?

During website operation, we often need to display various list data, such as article lists, product lists, image galleries, or navigation menus.AnQiCMS (AnQiCMS) provides a powerful mechanism based on the Go language template engine, where the `for` loop tag is the core tool to meet this requirement.By flexibly using the `for` tag and its auxiliary functions, we can easily traverse array or list data and accurately control the display style of each element according to actual needs.

2025-11-08

How to set up a canonical link (CanonicalUrl) in article content and ensure it displays correctly on the page?

In website operation, we often encounter situations where content is similar or repetitive, which may not only scatter the search engine's crawling budget, but also dilute the page weight, affecting SEO performance.Fortunately, AnQi CMS provides us with the function to set canonical links (Canonical URL), which can effectively help us solve these problems and clearly inform search engines which page is the 'original' or 'preferred' version of the content.The value of understanding the significance of canonical URL in simple terms

2025-11-08

How to configure and display structured data (Json-LD) in AnQiCMS to enhance search engine understanding?

In today's digital world, search engines are the main way users discover website content.In order to help search engines better "understand" the content on our website, structured data plays a crucial role.Json-LD (JSON for Linking Data) is a lightweight, easy-to-implement standardized data format that can clearly describe web content in a structured way, thereby enhancing the visibility and display effects of websites in search results.AnQiCMS as a content management system focusing on SEO optimization

2025-11-08

How to set a default thumbnail in AnQiCMS to ensure that articles without uploaded thumbnails can still display images?

It is crucial to maintain the visual appeal and consistency of content in website operation.Many times, the articles we publish may not have a specific picture, or the editor may have missed uploading the thumbnail, which may lead to blank pages or inconsistent styles.AnQiCMS (AnQiCMS) has fully considered this user requirement and provided flexible default thumbnail setting features to ensure that even articles without individually uploaded thumbnails can have beautiful image displays.Why do you need to set a default thumbnail?\n\nA default thumbnail is like a "backup plan" for a website.

2025-11-08