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