AnQiCMS Multi-site Data Call: Easily realize content sharing and联动 display

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

It is fortunate that AnQiCMS provides us with a powerful and flexible solution —— through template tags,siteIdParameter, can easily realize cross-site data call and display, greatly improves the efficiency and flexibility of content operation.

Core mechanism: UnderstandingsiteIdParameters

In AnQiCMS, each independent site created through the "Multi-site Management" feature in the backend will have a unique numeric ID.This ID is the 'magic key' we use for cross-site data calls.

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

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

to query the specific sites.siteIdYou can log in to the AnQiCMS backend and go to the "Multi-site Management" page.Here, each site created will clearly list its corresponding ID, making it convenient for you to check and use it at any time.

Actual operation: Call data through template tags

Most core template tags of AnQiCMS are supportedsiteIdParameters, including:

  • Document-related tags: archiveList(文档列表),archiveDetail(Document details)
  • Category-related tags: categoryList(分类列表),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 page Banner),linkList(Friend link)
  • Tag tags: tagList(Tag list),tagDetail(Tag details),tagDataList(Tag document list)
  • Message form: guestbook(留言表单)

下面,我们通过几个常见的场景来演示如何使用siteIdParameters:

1. 调用其他站点的文章或产品列表 (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 enrich the content, you can write it like this in the template of the child site:

{# 假设主站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 retrieve the latest 5 article titles and links from the site with 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. Assuming 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 ensures consistency by displaying the contact information and contact person from the headquarters site with ID 1 for any regional site.

3. Display shared navigation menu (navList)

You may want all sub-sites to share a set of universal footer navigation menus, which are managed uniformly in 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 %}

Through this method, 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. Introducing 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 redundant configuration and potential errors.

Application scenarios and value

PasssiteIdThe parameter implementation of cross-site data call brings significant value to AnQiCMS users:

  • Improve efficiency:Avoided the repetition of creating and managing the same content across multiple sites, especially public information such as contact details, navigation, announcements, etc.
  • Maintain consistency:Ensured the consistency of shared content across all related sites, which helps to strengthen the brand image and the accuracy of information transmission.
  • Content aggregation and linkage:Easily implement content linkage from a "center site" to other "distribution sites", or aggregate content from multiple sites to a display page.
  • Simplify maintenance:When sharing content needs to be updated, it only needs to be modified at one site (the content source site), and other calling sites will be automatically synchronized, which greatly reduces the maintenance cost.

Precautions

When usingsiteIdWhen performing cross-site data calls with parameters, there are a few points to note:

  1. Be clear about the target ID:Ensure you accurately know the ID of the target site you want to call the data from. Checking in the "Multi-site Management" section in the background is the best method.
  2. Data type matches:Ensure that the data type you are calling (such as article list, contact information) exists in the target site, otherwise it may return empty data.
  3. Template output structure:Cross-site calls will only provide data, how to beautifully display these data still needs layout and style design in the template.

Summary

AnQiCMSsiteIdParameters are its multi-site management function