How to call the document data of different sites (`siteId`) through the `archiveList` tag?
As an experienced website operations expert, I fully understand the challenges you may encounter when managing content across multiple sites.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful multi-site management capabilities.Today, we will delve into how to make use ofarchiveListLabel and its core parameterssiteIdTo easily implement cross-site document data calls.
Unlock the magic of Anqi CMS multi-site content: how to use it cleverlyarchiveListTag calls for document data from different sites
In the digital age, many companies and content operators may have multiple brand websites, sub-sites, or specific content branches, and these sites often need to share or aggregate some content.AnQi CMS is born for this, its unique multi-site management function makes everything orderly.And when we want to display exciting content from another site on a site,archiveListLabel collaborationsiteIdParameters have become our reliable assistants.
AnQi CMS multi-site management: the art of data isolation and intercommunication.
The AnQi CMS treats each independently operated website as a 'site', each of which has its own unique data storage space, including articles, categories, pages, etc.This design ensures data isolation, allowing the operation of each site to be mutually undisturbed.However, the wisdom of operation lies in connection and integration. Anqi CMS is well-versed in this, providing a bridge for data intercommunication through a unified template tag system, and cleverly providessiteIdParameters are the key identifiers of this bridge.
In simple terms, when you create and manage multiple sites on the Anqi CMS backend, the system assigns a unique digital ID to each site, which issiteIdThis ID is the 'ID card' for each site, and it is also the reference for cross-site data calls.
Get to knowarchiveListTag: the core tool for content aggregation
archiveListThe tag is a universal tag used in Anqi CMS template engine to retrieve document lists (such as articles, products, news, etc.).It is powerful and can filter and display documents based on various conditions (such as category ID, module ID, recommended attributes, sorting method, display quantity, etc.).
AndsiteIdThe parameter is exactlyarchiveListTags implement the 'secret weapon' for cross-site data calls. The official documentation clearly states:
siteIdGenerally, it is not necessary to fill in, if you use the multi-site management on the backend to create multiple sites and want to call data from other sites, you can specifysiteIdTo call the data of the specified site.
This means, by default,archiveListThe data will be searched on the site currently running. But as long as we specify it clearlysiteIdit will 'cross over' to the target site, fetching document data from there.
Practice operation: how to usesiteIdPerform cross-site calls
Now, let's look at a specific example to see how we can flexibly use it in a templatesiteId.
Suppose you have a main site (siteIdand a news sub-site (siteIdFor 2). You want to display the latest 5 news articles from the news sub-site on the homepage of the main site.
First, you need to confirm your news sub-site in the multi-site management function of the Anqi CMS background.siteId. Usually, this ID can be found in the site list or the URL of the site editing page. For example, if the news sub-sitesiteIdis 2.
Next, in the template file of the main site (such asindex.htmlWithin some content block), you can write it like thisarchiveListTags:
{# 在主站点的模板中调用新闻子站(siteId=2)的最新新闻 #}
<div class="latest-news-from-subsite">
<h2>来自新闻子站的最新报道</h2>
<ul>
{% archiveList newsList with siteId="2" moduleId="1" order="id desc" limit="5" %}
{% for item in newsList %}
<li>
<a href="{{ item.Link }}" target="_blank">
<h3>{{ item.Title }}</h3>
<p>{{ item.Description|truncatechars:100 }}</p>
<time>{{ stampToDate(item.CreatedTime, "2006-01-02") }}</time>
</a>
</li>
{% empty %}
<li>当前新闻子站暂无最新内容。</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
Code analysis:
{% archiveList newsList with siteId="2" ... %}We define a variable namednewsListA variable to store the result. The key issiteId="2"This explicitly tells the tag to get data from the site with ID 2.moduleId="1"Here we assume that the news of the news sub-station is published using the article model (usually ID 1). You need to adjust this ID according to the actual situation.order="id desc": Documents are sorted in descending order by document ID, usually the ID of the most recently published document is the largest.limit="5": Only the latest 5 news items are retrieved.target="_blank"To improve user experience, when clicking on a link, the news content will open in a new tab.
By making such a simple setting, the main site can dynamically pull and display the content of the news sub-site.This way greatly improves the reusability of content, simplifying the management process of cross-site content.
siteIdWidespread application of parameters: not justarchiveList
It is worth mentioning,siteIdThe scope of application of parameters is far beyond.archiveListTags. In the AnQi CMS template design, many other key tags also supportsiteIdTo achieve a more comprehensive cross-site data call. This means that you can retrieve and display from other sites:
- Category list (
categoryList): such as a shared product category tree. - Site configuration information (
system): Obtain the website name, Logo, etc. of a sub-site. - Contact information (
contact): Display the contact information of the same company headquarters on different sites. - Navigation list (
navList): Share common navigation menu. - Page details (
pageDetail): Call some common "About Us" or "Contact Us" page content.
This design philosophy makes AnQi CMS extremely flexible and powerful in multi-site management, providing unlimited possibilities for content operators.
Operational Strategy Proposal
Reasonably utilize in practical operationsiteIdCross-site data calls can help you:
- Aggregate contentIntegrate selected content from various sub-sites on the main site to form a content matrix.
- Unify brand imageEnsure brand consistency by sharing design elements, contact information, etc.
- Optimize SEOEnhance the visibility of site content through internal link structure.
- Improve operational efficiencyAvoid creating and managing identical or similar content.
But, also, it is important to pay attention to reasonable planning.siteIdThe calling logic should avoid excessive cross-site requests that may affect performance unnecessarily. For frequently accessed data, consider using caching strategies in conjunction to optimize loading speed.
Frequently Asked Questions (FAQ)
Q1: How do I know my site'ssiteIdare?
A1:Generally, you can enter the "Multi-Site Management" feature after logging into the Anqi CMS backend.In the list of sites, each site will display a unique ID.In addition, when you click on a site to edit, the URL in the browser address bar often also containssiteIdParameters (for example/system/site/edit?id=2ofid=2)
Q2: Can I call data fromarchiveListmultiple differentsiteIddocuments in a tag?
A2: archiveListlabel'ssiteIdParameters can only specify one site ID at a time. If you need to aggregate document data from multiple sites, the usual practice is to use multiplearchiveListtags, each tag specifying onesiteIdThen they merge or display the data they receive in the template.
Q3: Will cross-site data calls affect the loading speed and performance of the website? A3:Any data call will incur some performance overhead. Although cross-site calls are convenient logically, if the call frequency is high, the data volume is large, and it involves multiple sites, it may cause additional load on the database server.