How does AnQiCMS call and display data for specific sites based on different site IDs?

Calendar 👁️ 68

AnQiCMS multi-site data call: easily achieve content sharing and联动 display

AnQiCMS is a content management system specially designed for small and medium-sized enterprises and content operation teams, and its multi-site management function is one of its core highlights.In the operation, we often encounter such needs: the main site needs to display the latest products of various child sites, or all child sites need to uniformly display the contact information of the company headquarters, or multiple content platforms hope to aggregate display articles on a specific theme.It is particularly important to efficiently call and display data from a specific site in this case.

Luckyly, AnQiCMS provides us with a powerful and flexible solution - through the template tags of thesiteIdParameters can easily implement cross-site data calls and display, greatly enhancing the efficiency and flexibility of content operations.

Core mechanism: UnderstandingsiteIdParameter

In AnQiCMS, each independent site created through the background "Multi-site Management" feature will have a unique numeric ID.This ID is the 'magic key' for us to perform cross-site data calls.

When we use various template tags of AnQiCMS in templates (such as getting article lists, category details, system settings, etc.), these tags will default to retrieving data from the current visited site. However, if we want to retrieve data from a non-current site, we just need to add it in the corresponding template tag.siteIdParameters, and specify the target site ID.

For example:If your main site ID is1, and you have a product display site ID is2In the product display site template, you can display the latest news of the main site by specifyingsiteId="1"to retrieve the data of the main site.

to query the specific information of each site.siteIdYou can log in to the AnQiCMS backend and go to the 'Multi-site Management' page.Here, each created site will clearly list its corresponding ID for easy reference and use at any time.

Perform actual operation: Call data through template tags

Most of the core template tags of AnQiCMS are supportedsiteIdParameters, including:

  • Document-related tags: archiveList(Document list),archiveDetail(document details)
  • Category related tags: categoryList(category list),categoryDetail(category details)
  • Page related tags: pageList(Single page list),pageDetail(Single page details)
  • General information label: system(System settings),contact(Contact information),tdk(TDK Information),navList(Navigation List),bannerList(Home Banner),linkList(Friend Links)
  • Tag Label: tagList(Tag list),tagDetail(Tag details),tagDataList(Tag document list)
  • 留言表单: guestbook(留言表单)

Below, we demonstrate how to use it through several common scenariossiteIdparameters:

1. Call the articles or product lists of other sites (archiveList)

Assuming your main site (ID 1) has released the latest industry news, and your child site (ID 2) wants to display these news in the sidebar to increase content richness. You can write it like this in the child site template:

{# 假设主站ID为1,调用主站ID为1的最新5篇文章 #}
{% archiveList archives with type="list" siteId="1" limit="5" %}
    {% for item in archives %}
    <li>
        <a href="{{ item.Link }}">{{ item.Title }}</a>
        <span>{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
    </li>
    {% endfor %}
{% else %}
    <li>暂无最新资讯</li>
{% endarchiveList %}

This code will fetch the latest 5 articles' titles and links from site ID 1 and display them on the current sub-site (ID 2).

2. Obtain contact information for a specific site (contact)

If your company has multiple regional sites but uses the headquarters' contact information for external communication. Assume the headquarters site ID is1You want all child sites to display this unified phone number.

{# 假设总部站点ID为1,调用其联系电话 #}
<p>联系电话:{% contact with name="Cellphone" siteId="1" %}</p>
{# 也可以调用其他信息,例如联系人 #}
<p>联系人:{% contact with name="UserName" siteId="1" %}</p>

This will display the contact phone number and contact person from the headquarters site with ID 1 for any regional site, ensuring consistency.

3. Show shared navigation menu (navList)

You may want all child sites to share a set of common footer navigation menus, which are managed centrally on the main site (ID 1).

{# 假设主站ID为1,调用其默认导航列表 #}
{% navList navs with siteId="1" %}
<ul>
    {% for item in navs %}
    <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
    {% endfor %}
</ul>
{% endnavList %}

In this way, once the footer navigation of the main station is updated, all child sites that have called this tag will be synchronized updated without the need to modify them individually.

4. Introduce general system configuration (system)

Some global configurations, such as the website filing number(SiteIcp) or unified copyright information(SiteCopyright) may need to be consistent across all sites.

{# 假设主站ID为1,调用其备案号和版权信息 #}
<p>备案号:{% system with name="SiteIcp" siteId="1" %}</p>
<p>版权信息:{% system with name="SiteCopyright" siteId="1" %}</p>

This ensures that brand information and legal statements are consistent across all sites, avoiding duplicate configurations and potential errors.

Application scenarios and value

BysiteIdParameters enable cross-site data calls, bringing significant value to AnQiCMS users:

  • Enhance efficiency:Avoided the repetition of creating and managing the same content across multiple sites, especially public information such as contact details, navigation, and announcements.
  • Maintain consistency:Ensured consistency of shared content across all related sites, helping to strengthen the brand image and the accuracy of information transmission.
  • Content aggregation and linkage: Easily achieve the linkage of content from a "central site" to other "distribution sites", or aggregate the content of multiple sites into a display page.
  • Simplify maintenance:When shared content needs to be updated, it only needs to be modified on one site (the content source site), and other calling sites will automatically synchronize, greatly reducing maintenance costs.

Points to note

While usingsiteIdWhen making cross-site data calls with parameters, there are several points to pay attention to:

  1. Be clear about the target ID:Make sure you accurately know the ID of the target site you want to call the data from. Checking in the "Multi-site Management" backend is the best method.
  2. Data type match: Make sure the data type you are calling (such as article list, contact information) exists on the target site, otherwise an empty response may be returned.
  3. Template output structure:Cross-site calls will only provide data, how to beautifully display these data still requires you to lay out and design styles in the template.

Summary

AnQiCMS'siteIdThe parameter is for multi-site management functionality

Related articles

How to add `hreflang` tags in AnQiCMS template for multilingual pages to optimize SEO?

In today's globalized internet environment, many websites need to provide content for audiences of different languages or regions.To ensure that these multilingual pages can be correctly understood and displayed by search engines, the `hreflang` tag plays a crucial role.It can tell search engines that your website has multiple language versions and which version should be displayed to which user.

2025-11-08

How to implement the link display for multi-language site switching in AnQiCMS?

In today's globalized digital world, multilingual support for websites has become crucial for reaching a wider audience and expanding market boundaries.AnQiCMS (AnQiCMS) fully understands this need, therefore, it takes multilingual support as one of its core features, aiming to help users efficiently build and manage multilingual websites.This article will focus on how to implement the display of language switch links for multi-language sites in AnQiCMS, supplemented by necessary SEO practices, and provide you with a comprehensive guide.

2025-11-08

How to define and use temporary variables in AnQiCMS templates to simplify content display?

When developing templates in AnQiCMS, we often encounter situations where we need to process some complex data or reuse a certain calculation result.To make the template code more concise, readable, and maintainable, AnQiCMS provides a powerful mechanism for defining and using temporary variables, mainly through the `with` and `set` tags.Reasonably utilizing them can greatly enhance our content display efficiency and flexibility. ### Simplified Content Display: Why do we need temporary variables?

2025-11-08

How to automatically parse a URL string into a clickable HTML link in AnQiCMS template?

In AnQiCMS template development, we often encounter the need: the URL string contained in the content should be automatically converted into a clickable HTML link to enhance user experience and page interactivity.Manually adding links is undoubtedly cumbersome and unrealistic, fortunately AnQiCMS provides powerful template filters that can help us easily achieve this function.AnQiCMS template engine supports Django-like syntax, which includes a series of practical filters that can process variable content.For automatic parsing of URL strings

2025-11-08

How to enable Markdown editor in AnQiCMS and display mathematical formulas and flowcharts correctly?

Today, with the increasingly rich content creation, plain text is no longer sufficient to express complex concepts.If complex mathematical formulas in academic articles or clear process diagrams in project management can be presented intuitively on the web, it will undoubtedly greatly enhance the professionalism and user experience of the content.AnQiCMS (AnQiCMS) understands this need, through the built-in Markdown editor and flexible frontend configuration, allowing you to easily implement these advanced content displays.This article will give a detailed introduction on how to enable Markdown editor in AnQiCMS

2025-11-08

How to correctly use the double curly braces `{{}}` and percentage signs `{% %}` tags in AnQiCMS templates to control the display logic of content?

When using AnQiCMS to build and manage websites, flexibly using template language is the key to improving efficiency and achieving personalized display.Among them, the double curly braces `{{}}` and the percentage tags `{% %}` are two core 'roles' that control the display logic of template files.They each have different responsibilities, understanding and using them correctly can help you easily master the powerful template functions of AnQiCMS.

2025-11-08

How to customize the AnQiCMS content model to meet the display needs of different content types (such as articles, products)?

In today's rapidly changing digital world, website content is no longer just simple articles or product introductions.In order to accurately reach users and improve conversion rates, we often need to tailor the display form and data structure of different types of content to meet their needs.AnQiCMS (AnQi content management system) fully understands this, and the flexible content model function it provides is a powerful tool to solve this challenge.

2025-11-08

How to configure the pseudo-static rules in AnQiCMS to optimize the URL structure and improve the display of content in search engines?

The importance of URL structure in a content management system is self-evident.A clear, concise, and meaningful URL not only enhances user experience but is also a key factor in search engine optimization (SEO).In AnQiCMS, by carefully configuring the pseudo-static rules, we can transform those dynamic URLs that may have complex parameters into static forms, thereby allowing the website content to display better in search engines.Understanding URL Rewriting: Why It Is Crucial for Your Website?Imagine, a web page address is `www

2025-11-08