Control the AnQi CMS multi-site:archiveParamstagssiteIdCross-site invocation practice of parameters

As an experienced website operations expert, I know that efficient content management and flexible content scheduling are crucial to business success in an increasingly complex online environment.English CMS (EnglishCMS) provides powerful tools for operators with its excellent multi-site management capabilities.archiveParamsHow to pass through tagssiteIdParameters to implement cross-site invocation of content.

Discover the charm of AnQi CMS multi-site management

The Anqi CMS has fully considered the needs of multi-site management from the very beginning, allowing enterprises and operation teams to easily build and uniformly manage 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 certain 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.

archiveParams标签:精准获取文档参数的核心工具

In the template system of Anqi CMS,archiveParamsis a powerful tag, its 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, etc.

{# 假设我们正在文档详情页,获取当前文档的所有参数 #}
{% archiveParams params %}
    {% for item in params %}
    <div>
        <span>{{ item.Name }}:</span>
        <span>{{ item.Value }}</span>
    </div>
    {% endfor %}
{% endarchiveParams %}

This code will display all custom parameter names and values within the context of the current document. However, when our focus turns to a multi-site environment,archiveParamsThe true potential will be fully released.

siteIdParameters: the key to building cross-site data bridges.

In the multi-site architecture of AnQi CMS, each independent site has a unique identifier, i.e., siteId. ThissiteIdIt is like the 'ID number' of each site. When you need to display specific document parameters of another site (e.g., site B) within the current site (e.g., site A),siteIdThe parameter has become the bridge connecting these two sites.

The document of Anqi CMS clearly states:

"siteIdIt is generally not necessary to fill in, if you use the multi-site management of the background to create multiple sites, and want to call data from other sites, you can do so by specifyingsiteIdTo implement the call to the specified site's data.

This means you no longer need to copy content or perform complex API integration, simply add aarchiveParamstag in it.siteIdThe parameter allows for easily pulling parameter information from the specified other sites. This ability greatly enhances the flexibility and efficiency of content operation.

实战演练:Cross-Site CallingarchiveParams

To better understandsiteId的实际应用,我们来模拟一个常见的场景:您的主品牌网站(站点A,假定其siteIdresponse for1)需要展示旗下子品牌网站(站点B,假定其siteIdresponse for2)中某个产品的特定参数。假设站点B有一篇产品文档,其ID为101We hope to obtain the "model" and "color" parameters of the product at site A.

Firstly, you need to confirm site B in the "Multi-site Management" feature of the Anqi CMS backend.siteId. Usually this ID will be displayed in the site list or site configuration details.

Next, you can use it like this in the template file of site AarchiveParamsTags:

<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":Explicitly specified the document ID to be retrieved.
  • siteId="2":This is crucial! It tells the security CMS to go to ID of2to find the parameters of this document in the site database.
  • productDetails.型号.Value:If 'Model' is a custom field, andsorted=false(i.e., when getting an unordered map object), you can access it directly. Ifsorted=true(To get an array of fixed sorted objects, you need to sort as shown in the example)forLoop traversal.

Through such an invocation, site A can dynamically display the relevant parameters of the products in site B, without the need for manual copy and paste. Once the product parameters in site B are updated, site A will also synchronize to display the latest data, ensuring the consistency and timeliness of the content.

siteIdThe wide application: not onlyarchiveParams

It is worth mentioning that,siteIdParameters are notarchiveParamsunique tags. In the template design of Anqi CMS, in order to achieve flexible data calls in multi-site environments, many core data acquisition tags supportsiteIdParameters. This includes but is not limited to:

  • archiveList: Get the document list of the specified site.
  • archiveDetail: Get the document details of the specified site.
  • categoryList: Get the category list of the specified site.
  • **`categoryDetail English