How to implement cross-site calls for the `siteId` parameter of the `archiveParams` tag in the AnQiCMS multi-site environment?
Govern the Anqi CMS multi-site:archiveParamsin the tagsiteIdCross-site parameter call practice
As an experienced website operations expert, I am well aware that efficient content management and flexible content scheduling are the key to business success in an increasingly complex network environment.AnQiCMS (AnQiCMS) provides powerful tools for operators with its excellent multi-site management capabilities.Today, let's delve into a very practical feature in a multi-site environment:archiveParamsHow to pass through the tagsiteIdImplement cross-site content call via parameters.
Insight into the charm of Anqi CMS multi-site management
The Anqi CMS has always fully considered the needs of multi-site management, allowing enterprises and operation teams to easily build and unify the management of multiple websites.This not only greatly reduces the repetitive workload, but more importantly, it provides a solid foundation for cross-site data sharing and resource integration.Imagine that your brand has multiple sub-sites, each possibly focusing on different product lines or service areas, but they need to share some common content or data - such as detailed parameters of a core product, or an important company announcement.At this moment, a simple and efficient cross-site content call mechanism is particularly important.
archiveParamsThe label: The core tool for accurately obtaining document parameters
In the template system of Anqi CMS,archiveParamsIt is a powerful tag, whose main responsibility is to obtain various parameters of the specified document.These parameters may include custom fields defined in the document model, such as product model, author, source, and so on.In most cases, we use it in the current site environment, for example:
{# 假设我们正在文档详情页,获取当前文档的所有参数 #}
{% archiveParams params %}
{% for item in params %}
<div>
<span>{{ item.Name }}:</span>
<span>{{ item.Value }}</span>
</div>
{% endfor %}
{% endarchiveParams %}
This code will be repeatedly displayed in the context of the current document, showing all the names and values of its custom parameters. However, when our gaze turns to the multi-site environment, ...archiveParamsThe true potential will be fully released.
siteIdParameter: The key to building a cross-site data bridge.
In the AnQi CMS multi-site architecture, each independent site has a unique identifier, namelysiteId. ThissiteIdIt is like the 'ID number' for each site. When you need to display specific document parameters of another site (like site B) within the current site (like site A),siteIdThe parameter becomes the bridge connecting these two sites.
The AnQi CMS documentation explicitly 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 implement calling data from a specified site.
This means, you no longer need to copy content, nor do you need complex API integration, just add inarchiveParamsa simple tagsiteIdParameters can easily retrieve the parameter information of the required documents from specified other sites. This ability greatly enhances the flexibility and efficiency of content operation.
Practice exercise: Cross-site callarchiveParams
In order to understand bettersiteIdApplication, let's simulate a common scenario: Your main brand website (site A, assuming itssiteIdWith1)Need to display the website of its subsidiary brand (site B, assuming itssiteIdWith2)specific parameters of a product. Suppose site B has a product document with the ID of101We hope to obtain the product's "model" and "color" parameters at site A.
Firstly, you need to confirm the site B's in the "Multi-site Management" feature of the Anqi CMS backend.siteId. This ID is usually displayed in the site list or site configuration details.
Next, in the template file of site A, you can use it like this.archiveParamsTags:
<h3>子品牌产品详情</h3>
{% archiveParams productDetails with id="101" siteId="2" %}
{% if productDetails %}
<p>产品型号:{{ productDetails.型号.Value }}</p>
<p>产品颜色:{{ productDetails.颜色.Value }}</p>
{# 也可以遍历所有参数,如果“型号”和“颜色”是自定义字段 #}
<h4>所有参数:</h4>
<ul>
{% for param in productDetails %}
<li>{{ param.Name }}:{{ param.Value }}</li>
{% endfor %}
</ul>
{% else %}
<p>未能找到站点B中ID为101的产品参数。</p>
{% endif %}
{% endarchiveParams %}
In this code block:
id="101": Specifically specified the document ID to be retrieved.siteId="2": This is crucial! It tells Anqi CMS to go to the ID of2and find the parameters of this document in the site database.productDetails.型号.ValueIf "model" is a custom field andsorted=false(i.e., when getting an unordered map object), you can access it directly. Ifsorted=true(To obtain an array of objects sorted in a fixed order, you need to pass it through the example as shown)forlooped through.
By making such a call, site A can dynamically display the related parameters of the products in site B, without manually copying and pasting. Once the product parameters in site B are updated, site A will also synchronize the display of the latest data, ensuring consistency and timeliness of the content.
siteIdThe wide application: not justarchiveParams
It is worth mentioning,siteIdThe parameter is notarchiveParamsThe tag is unique. In the template design of Anqi CMS, in order to achieve flexible data calling in a multi-site environment, many core data acquisition tags are supportedsiteIdParameters. This includes but is not limited to:
archiveList: Retrieve the document list of the specified site.archiveDetail: Retrieve the document details of the specified site.categoryList: Retrieve the category list of the specified site.- **`categoryDetail