How to call and display specific content or system configuration information from other sites in a multi-site management mode?

AnQiCMS powerful multi-site management function, bringing great convenience to users with multiple brands or sub-sites.It not only allows you to manage different content sites uniformly, but also supports cross-site data sharing and resource integration.When you want to display content from other sites on a site, or call system configuration information from other sites, AnQiCMS provides a simple and efficient mechanism to achieve this goal.

In AnQiCMS, the core of implementing cross-site content or configuration information calls lies in the flexible use of template tags.siteIdA parameter that acts like a site identifier, clearly telling the system which specific site you want to retrieve data from. By specifying this parameter for various content and configuration-related template tags,siteIdYou can easily display the latest articles of the sub-site on your main site, or call the contact information of the corporate website on the product site, etc.

Call content information from other sites

Imagine you have a corporate website and a sub-site dedicated to publishing industry news.If you want to display the latest five news of the sub-site on the homepage of the corporate website, you do not need to copy and paste manually, nor do you need complex secondary development. UtilizearchiveListLabel and specify the sub-site.siteIdand it is done:

{% archiveList latestNews with type="list" limit="5" siteId="您子站的ID" %}
    {% for item in latestNews %}
        <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
    {% endfor %}
{% endarchiveList %}

here,siteId="您子站的ID"It is the key. It indicates that the system retrieves the article list from the sub-site specified by the ID.

Similarly, if you need to display the detailed information of a specific article, such as a product introduction page, you can usearchiveDetailTags:

{% archiveDetail productDetail with name="Content" id="指定文章ID" siteId="您产品站的ID" %}
    <div class="product-description">{{ productDetail|safe }}</div>
{% endarchiveDetail %}

By specifyingidandsiteId, you can accurately obtain the specific content fields of a specific site.

This mechanism also applies to other types of content tags. For example, if you want to list the category list of a sub-site, you can usecategoryList:

{% categoryList subSiteCategories with moduleId="1" parentId="0" siteId="您子站的ID" %}
    {% for category in subSiteCategories %}
        <a href="{{ category.Link }}">{{ category.Title }}</a>
    {% endfor %}
{% endcategoryList %}

or call the details of a specific single page:

{% pageDetail aboutPage with name="Content" token="about-us" siteId="您子站的ID" %}
    <div>{{ aboutPage|safe }}</div>
{% endpageDetail %}

Even can obtain the tag cloud of other sites or a document list related to a tag, justtagListortagDataListto includesiteIdthe parameter.

Call the system configuration information of other sites

In addition to the content, you may encounter situations where you need to call system configuration information from other sites, such as contact information, website logo, filing number, etc.AnQiCMS provides convenience for this as well.

systemTags allow you to obtain various global system configurations:

<img src="{% system with name="SiteLogo" siteId="您官网的ID" %}" alt="Logo">
<p>{% system with name="SiteCopyright" siteId="您官网的ID" %}</p>

Here, siteId="您官网的ID"You can easily obtain the logo address and copyright information set by the official website, without repeating the configuration on each sub-site.

If you need to display contact information for another site,contactTags also support.siteIdparameters:

<p>联系电话:{% contact with name="Cellphone" siteId="您其他站点的ID" %}</p>
<p>联系邮箱:{% contact with name="Email" siteId="您其他站点的ID" %}</p>

This is particularly useful when building a unified customer service or information display page.

Even the page's TDK (Title, Keywords, Description) information can be accessed throughtdkSpecify the tagsiteIdto call:

<title>{% tdk with name="Title" siteId="您其他站点的ID" %}</title>

Furthermore,navListTags also supportsiteIdThis means you can even display a navigation menu from another site on a site, achieving a higher level of unity and reuse.

How to obtainsiteId

So, how can you know different sitessiteIdWhat? On the AnQiCMS backend management interface, you can view the detailed information of all sites created through the "Multi-site Management" feature, which usually includes a unique identifier for each site, namelysiteId. This ID is usually a number, just replace it in the template tag.siteIdthe parameter.

This cross-site calling capability provided by AnQiCMS greatly enhances the efficiency and flexibility of multi-site operations. Whether it is content aggregation, unified brand image, or centralized management of core information,siteIdParameters all play an indispensable role, making your multi-site ecosystem closer and more efficient.


Frequently Asked Questions (FAQ)

  1. In which types of template tags can I usesiteIdthe parameter? siteIdParameters almost support all AnQiCMS template tags related to content and system configuration, includingarchiveList(Document list),archiveDetail(Document details),categoryList(category list),pageDetail(Single page details),tagList(Tag list),system(System Configuration),contact(Contact information),tdk(Page TDK),navList(Navigation List) etc. Whenever you need to fetch data from a non-current site, you can usually try usingsiteIdparameters to specify the source.

  2. Does calling data from other sites affect the loading speed of the current site?Due to AnQiCMS being a high-performance content management system developed in Go language and usually deployed on the same server for multiple sites, therefore throughsiteIdThe internal data call is usually very efficient, with little impact on the loading speed of the current site.If a large amount of data from other sites is called, or the target site itself has a large amount of data and complex queries, it is still recommended to perform performance testing and consider caching the data to optimize the user experience.

  3. If I specifysiteIdWhat if it does not exist, or the site does not have the content I requested?IfsiteIdThe requested content does not exist or was not found on the target site (for example, the requested article ID does not exist on the target site). AnQiCMS template tags usually return an empty value or an empty collection.This means that your page will not crash due to missing data, but will display a blank space or the alternative information you set up for the 'no content' situation in the template.To improve user experience, it is recommended to add judgment to the tags in the template that may return null values, such as{% if item %}or{% empty %})to deal with this situation.