When using AnQiCMS for website management, the multi-site feature undoubtedly brings great convenience to users with multiple brands, sub-sites, or content branches.It allows us to efficiently manage multiple independent websites on a unified backend.However, in actual operation, we sometimes encounter a specific requirement: to display the content of another specific site on a site.For example, the main station wants to refer to some of the latest articles of the child station, or a specific thematic station wants to display product information from another cooperative site.

At this time, 'How can specific content be displayed by calling a specific site through tag parameters in a multi-site environment?'It has become a key issue. Fortunately, AnQiCMS considered this cross-site content call scenario from the beginning of its design and provided a simple and effective solution through its powerful template tag system.

AnQiCMS Multi-site Management Overview

The multi-site management feature of AnQiCMS is one of its core highlights.It allows us to easily create and maintain multiple independent websites under the same system.Each site can have its own domain, content, template, and database (or different prefixes of a shared database), but all operations can be completed in a single backend interface.This design not only reduces the complexity of duplicate construction and management of multiple independent CMSs, but also provides a unified platform for content operation and resource integration.

Through multi-site management, we can easily build corporate websites, product display pages, blogs, marketing special topic pages, and various types of sites, and flexibly configure according to business needs.When it is necessary to establish content linkage between different sites, the template tags of AnQiCMS play a key role.

Core mechanism:siteIdParameter

The secret weapon of AnQiCMS for cross-site content calls lies in the widely supported template tags.siteIdThe parameter. Almost all tags used for content calls, such as getting article lists, category details, single-page content, contact information, and even system configuration, include this parameter.

siteIdThe parameter's role is very direct: it tells the template tag to get data from which site (identified by the site's ID) instead of getting the data from the current site by default. By simply adding in the tagsiteId="X"(Where X is the ID of the target site), we can precisely specify the source of the content.

Practical case: Cross-site content calling

Let's look at some specific examples to see.siteIdHow parameters work.

1. Call the article list of a specific site

Assuming we have a main site, we hope to display the latest product articles of the sub-site "Product Release Center" on its homepage. We can use the template of the main site to,archiveListLabel and specify the 'Product Release Center' ofsiteId.

First, we need to know the 'Product Release Center' ofsiteId. This ID is usually found in the "Multi-site Management" list in the AnQiCMS backend. Assume its ID is2, and the product model ID is2.

{# 假设当前是主站,要调用siteId为2的站点的最新产品文章 #}
<div class="latest-products">
    <h2>产品发布中心最新动态</h2>
    {% archiveList products with moduleId="2" siteId="2" type="list" limit="5" order="id desc" %}
        {% for item in products %}
            <div class="product-item">
                <h3><a href="{{ item.Link }}" target="_blank">{{ item.Title }}</a></h3>
                <p>{{ item.Description|truncatechars:100 }}</p>
                <span>发布日期: {{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
            </div>
        {% empty %}
            <p>暂无最新产品。</p>
        {% endfor %}
    {% endarchiveList %}
</div>

BysiteId="2",archiveListThe tag will retrieve content from the site with ID 2, ensuring that we obtain data from the correct source.

2. Display the category information of another site.

Maybe we hope to list the article categories of another special site in some sidebar of the main station. Similarly, we can usecategoryListTags andsiteId. Assuming the articlesiteIdWith3, the article model ID is1.

{# 调用siteId为3的专题站点的文章分类列表 #}
<div class="topic-categories">
    <h3>专题分类导航</h3>
    <ul>
        {% categoryList categories with moduleId="1" parentId="0" siteId="3" %}
            {% for category in categories %}
                <li><a href="{{ category.Link }}" target="_blank">{{ category.Title }}</a></li>
            {% endfor %}
        {% empty %}
            <li>暂无分类信息。</li>
        {% endfor %}
    </ul>
</div>

here,siteId="3"Make sure we see the classification structure of the special site, not the current site.

3. Obtain the system configuration or contact information of a specific site.

Sometimes, we need to display contact information of other sites on a certain site, or some custom global configuration.systemandcontactTags also supportsiteIdAssuming we want to display the contact phone number of a sub-site "Contact Us" on the main site, the sub-sitesiteIdWith4.

{# 调用siteId为4的站点的联系电话 #}
<div class="contact-info">
    <p>欲了解更多信息,请致电:</p>
    <span>电话:{% contact with name="Cellphone" siteId="4" %}</span>
</div>

BysiteId="4"We can accurately obtain the phone number of the specified sub-site.

How to obtainsiteId

To usesiteIdThe parameter requires knowing the ID of the target site. This information is usually available in the 'Multi-site Management' module of the AnQiCMS backend.In the site list, each site will have a unique numeric ID identifier.

Cautionary notes and **practice

When making cross-site content calls, there are some details to note to ensure the performance, user experience, and SEO effects of the website.

  • Confirm that the content of the target site has been published: Only the content that has been published on the target site can be called and displayed. Drafts or unreviewed content will not be displayed on the front end.
  • Performance consideration: Although the Go language foundation and high-performance architecture of AnQiCMS can effectively handle data requests, there may still be an impact on page loading speed when performing a large number of complex cross-site content calls on a page.Recommend evaluating actual needs and reasonably limiting the number of calls.
  • SEO impact: Cross-site content calls, if not handled properly, may cause search engines to believe that there is duplicate content. To avoid this situation, consider usingrel="canonical"The tag points to the original URL of the content or usesnoindex,followmeta tags to guide search engines.
  • Data consistencyEnsure that the content called at the source site is accurate and up-to-date. Any updates to the source site will be reflected in real-time on the page calling the content.
  • Consistency in template design: When calling content across sites, consider whether the display style of the target content is consistent with the design style of the current site to avoid a jarring visual experience.

Summary

The multi-site management feature of AnQiCMS, combined with its flexible template tag system, is especiallysiteIdParameters, provide strong support for building complex, highly interconnected website groups. By making reasonable use ofsiteIdWe can achieve seamless content sharing and display between different sites, greatly enhancing the efficiency of content operation and the overall value of the website.Mastering this feature will make you more proficient in managing multi-site content, easily dealing with various business scenarios.


Frequently Asked Questions (FAQ)

Q1: How do I know the site I want to call?siteIdare?A1:siteIdCan be found on the 'Multi-site Management' page in the AnQiCMS backend.After logging in, navigate to the "Multi-site Management" menu, where you will see a list of all sites created, each site usually has a unique numeric ID.

Q2: Will cross-site content calls affect website performance?A2: Any data call will incur some performance overhead.AnQiCMS is based on the Go language, with high-performance features, usually handles these requests well.If your page makes a large number of complex cross-site content calls, it may indeed affect the page loading speed.It is recommended to perform performance testing after actual deployment and optimize the call strategy based on the results, such as limiting the number of calls, utilizing caching mechanisms, etc.

Q3: Can I call any content from any site? Are there any restrictions?A3: In theory, as long as you correctly specify in the template tagsiteIdand provided the correct content type (such as article model ID, category ID, etc.), you can call the public content of any site.The restriction mainly lies in the visibility of the content (for example, unreleased draft content cannot be accessed) and the parameter range supported by the tag itself.Content that is private or protected by permissions is usually not displayed in this way.