Under AnQiCMS multi-site management, how to accurately call the custom content of a specific site using the `{% diy %}` tag?

Calendar 👁️ 61

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

Related articles

How should the `name` parameter of the `{% diy %}` tag be set correctly to retrieve custom data from the backend?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system, whose powerful custom functions are an important tool for website operators to improve efficiency and achieve personalized display.In daily content operation, we often encounter situations where we need to call back-end preset but non-standard field data, and the `{% diy %}` tag is exactly for this purpose.How should the `name` parameter of this tag be set to accurately obtain the custom data from the backend?Let's delve into it in depth.

2025-11-06

How to use the `{% diy %}` tag to display custom information configured on the back-end page?

As an experienced website operations expert, I fully understand how important the flexibility and update efficiency of website content are in the increasingly fierce online competition.AnQiCMS (AnQiCMS) with its powerful functions and friendly template system provides us with many operational tools.Today, let's delve into one of the very practical 'magic box' - the `{% diy %}` tag, and see how it helps us easily control the custom information of the front-end page, making website content operation more intelligent and efficient.

2025-11-06

What is the core use of the `{% diy %}` custom content tag in AnQiCMS?

## Core Usage Deep Analysis of Custom Content Tags in Anqi CMS `{% diy %}` As an experienced website operations expert, I fully understand the importance of a flexible and scalable content management system for efficient website operations.AnQiCMS (AnQiCMS) stands out among many CMS products with its powerful customization capabilities.In its rich template tag system, the `{% diy %}` (Do It Yourself) custom content tag is undoubtedly a core tool for achieving high website personalization and operational efficiency optimization.

2025-11-06

How to ensure that all external social media links called by the `contact` tag open in a new window when clicked?

As an experienced website operations expert, I am well aware of the importance of website details for user experience and brand image.In content operation, we often need to guide users to visit external social media platforms to expand influence or provide more interactive channels.AnQiCMS (AnQiCMS) takes advantage of its flexible template tag system, making such operations intuitive and efficient.However, a common detail that is often overlooked is: How to ensure that these external links open in a new window or tab when clicked, thus avoiding users leaving your main site?Today, let's delve deeply into this issue

2025-11-06

If the custom content information is not set on the backend, what will the `{% diy %}` tag return on the front end?

AnQiCMS (AnQiCMS) with its flexibility and powerful customization capabilities has become the preferred tool for many enterprises and content operators.The `{% diy %}` tag is the key to displaying dynamic content, allowing us to customize various information in the background and present it on the website front end.What if the backend does not set a specific custom content, and the front end uses the `{% diy %}` tag to call it?As an experienced website operations expert, I am happy to delve deeply into this mechanism.### Understand `{%

2025-11-06

How to implement a custom global website title or subtitle display using the `{% diy %}` tag?

## How to cleverly use the `{% diy %}` tag of AnQi CMS: Create personalized global website title and subtitle Maintaining brand image consistency and content update flexibility is crucial in website operation.Especially the global title and subtitle of the website, which are not only the first impression visitors have of the website content, but are also key elements of search engine optimization (SEO).

2025-11-06

`{% diy %}` label and the system built-in `{% system %}` or `{% contact %}` label what are the similarities and differences?

AnQi CMS as an efficient enterprise-level content management system, its template tag system provides great flexibility for content display.When building a website, we often need to fetch various data from the backend and display it on the frontend page.Among these, `{% system %}`, `{% contact %}`, and `{% diy %}` are all used to obtain information from the background configuration, but they have subtle differences in functional emphasis, data source, and application scenarios.Understanding these similarities and differences can help us use these tools more efficiently and rationally, creating a clear structure

2025-11-06

What types of 'custom content information' can I create in the background for the `{% diy %}` tag to call?

As an experienced website operations expert, I am well aware of how crucial it is to manage and call various contents flexibly in daily work.AnQiCMS (AnQiCMS) performs very well in this regard, it provides a series of powerful tags, making content operation effortless.Today, let's delve into it deeply. As a user of Anqi CMS, you can create what types of custom content information in the background, and call it flexibly in the front-end of the website through the `{% diy %}` tag.

2025-11-06