In the powerful ecosystem of AnQi CMS, multi-site management is undoubtedly one of its core highlights, granting enterprises the ability to operate multiple brands or sub-sites on the same platform.However, in the process of content operation, we often encounter such needs: how to flexibly call specific custom content from another child site in the main site template?{% diy %}Label, combined with its cleversiteIdParameters, have become our powerful assistant in achieving this goal.

The multi-site design concept of AnQi CMS aims to provide users with a highly independent and unified management experience.Each site has its own configuration, content, template, and custom settings, which do not interfere with each other and can be smoothly switched and coordinated through the management backend.siteIdThis number ID is the 'ID card' that allows us to accurately locate content across different sites.

{% diy %}The tag itself is a very practical tool in the AnQi CMS template engine, its main responsibility is to obtain the custom content in key-value pair form configured by the current site's background "Global Settings", "Contact Information Settings", or through the "Custom Parameters" feature. For example, if you have customized a parameter named "CompanySlogan" in the "Global Settings" of a site and filled in its value with "Innovation leads, service first", then you can pass through the template of the current site.{% diy with name="CompanySlogan" %}Relax and show it easily.

However, when our needs are no longer limited to the current site, but we want to call the main site (such assiteIdfor 1) template, call the product site (such assiteIdCustomer service phone number for 2) or a blog site (such assiteIdwhen writing the author's bio for 3), only using{% diy with name="参数名" %}is not enough. At this time,siteIdThe parameter shines on the scene, allowing us to clearly specify the site ID of the content source.

The first step to achieve cross-site calls is to understand the target site.siteId.In the Anqi CMS backend, through the "Multi-site Management" list, you will clearly see the unique digital ID corresponding to each site.{% diy %}tagssiteIdParameters to accurately obtain the required content.

For example, suppose we have a main brand website (siteIdwith a value of 1), and there is also a dedicated product showcase sub-site (siteIdTo be 2). Now, we hope to display the exclusive customer service phone number of the product sub-site in the footer of the main website, and this phone number is set as a custom parameter in the contact information settings of the product sub-siteCustomerServicePhoneSaved. Then, in the main website template files, we can write it like this:

{# 假设当前是主站(ID为1),需要从产品子站(ID为2)和博客子站(ID为3)获取信息 #}

<footer class="main-footer">
    <p>版权所有 © {% now "2006" %} {% system with name="SiteName" %}. All Rights Reserved.</p>

    {# 调用主站的联系电话(假设主站后台设置了自定义参数 MainContactPhone) #}
    <p>主站联系电话:{% diy 主站电话 with name="MainContactPhone" %}{{ 主站电话 }}</p>

    {# 从产品子站(Site ID 2)调用其客服电话(假设产品站后台设置了自定义参数 CustomerServicePhone) #}
    <p>产品站客服:{% diy 产品站客服电话 with name="CustomerServicePhone" siteId="2" %}{{ 产品站客服电话 }}</p>

    {# 从博客子站(Site ID 3)调用其作者信息(假设博客站后台设置了自定义参数 BlogAuthorName) #}
    <p>博客站作者:{% diy 博客站作者 with name="BlogAuthorName" siteId="3" %}{{ 博客站作者 }}</p>

    {# 同时,我们也可以使用 system 标签配合 siteId 获取目标站点的基础信息,如 BaseUrl #}
    <p>访问我们的 <a href="{% system with name="BaseUrl" siteId="2" %}" target="_blank">产品站点</a> 获取更多详情。</p>
</footer>

In this example,{% diy 产品站客服电话 with name="CustomerServicePhone" siteId="2" %}It will explicitly tell Anqi CMS to look forsiteIdThe site number 2 and extract the namedCustomerServicePhoneThe custom parameter value. Similarly,{% diy 博客站作者 with name="BlogAuthorName" siteId="3" %}It will pull author information from the blog site with ID 3.This makes content management more flexible, enabling information sharing and linkage between different sites without manual copy and paste, greatly enhancing operational efficiency.

In practice, to maintain the cleanliness and maintainability of the template, it is recommended that you use unified custom parameter names for the same type of information across different sites. For example, all child sites' customer service phone numbers are named asCustomerServicePhoneSo that it can be changed when called on the main sitesiteIdAs is, the template code can maintain high consistency. This design approach not only makes the website content more flexible, but also provides a solid foundation for future business expansion.

In summary,{% diy %}with the tag andsiteIdThe combination of parameters is the core secret to achieving precise content calling under AnQi CMS multi-site management.It makes cross-site content integration simple and intuitive, bringing unprecedented flexibility and efficiency to content operations.


Frequently Asked Questions (FAQ)

How to determine the target sitesiteId?You can log in to the Anqi CMS backend management system, go to the "Multi-site Management" feature page. On this page, all sites created will be displayed in a list format, with each site clearly marked with its unique numeric ID, which is where you are{% diy %}The label needs to usesiteId.

2. If the target site is not configured{% diy %}How will the template perform with the custom parameters specified by the label?If the target site (specified bysiteIdhas not configured the one you specified in{% diy %}TagnameParameter-specified custom content, if the tag will not output any content, it will usually return an empty string. To avoid blank pages or errors, you can use conditional judgments in the template (such as{% if 变量名 %}Check if the variable exists or has a value.

**3