AnQiCMS (AnQiCMS) is an efficient and flexible content management system, and its powerful multi-site management function is undoubtedly a highlight that many operators are keen on.When we have multiple brands, multiple regions, or multiple thematic websites, we can manage them uniformly through a single system, and flexibly call and display data between different sites, which will greatly enhance work efficiency and content integration.How can we implement the calling and display of data between different sites in the AnQiCMS multi-site environment?
Understanding the core of multi-site data calling: Site ID
In the AnQiCMS multi-site architecture, each independent website is assigned a unique identifier by the system, which we call the "site ID" (siteId)。ThissiteIdIt is the key to cross-site data interaction. When you want to display content from another site in a page template on a site, you need to explicitly tell AnQiCMS the target content'ssiteIdWhat is it.
By default, AnQiCMS template tags are not explicitly specified.siteIdWhen a parameter is passed, it will automatically identify and operate on the data of the current site. This makes it unnecessary for us to intervene much when developing templates for a single site. However, once it involves cross-site calls, thissiteIdParameters become the bridge to connect data between different sites.
Actual operation: Example of cross-site data call
The AnQiCMS template system is designed to be very flexible, almost all tags used to retrieve data are built-insiteIdParameters. This makes cross-site data calls direct and easy to understand. Next, we will look at several common application scenarios in detail.siteIdHow it works.
Scenario one: Display the latest article list of the child site on the main site
Assuming we are operating a main brand website, we also have a dedicated sub-site for product news.Now, we hope that the homepage of the main brand website can display the latest 5 article titles and links of the sub-sites in real time.
If the child site'ssiteIdIs2, we can write the code in the template of the main site like this:
{% archiveList subSiteArchives with siteId="2" type="list" limit="5" order="id desc" %}
{% for item in subSiteArchives %}
<li>
<a href="{{item.Link}}">{{item.Title}}</a>
<span>发布于: {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
</li>
{% endfor %}
{% endarchiveList %}
By this simple code, the main brand website can dynamically pull and display the latest article list of the child site.When users click on these links, they will be directly redirected to the corresponding article detail page on the child site, achieving seamless connection between sites.
Scenario two: Call the contact information of different regional sites uniformly
Imagine a company with multiple regional branches, each with its own independent website (subsite), and different contact numbers and addresses.We hope to display the contact information of all branches on a unified 'Contact Us' overview page.
Assuming we know all the branchessiteIdfor example2/3/4),we can loop through thesesiteIdto dynamically obtain information:
`twig {% set regionalSiteIds = "2,3,4"|split:"," %} {# This is your list of all regional site IDs #}