As an experienced website operations expert, I am well aware that how to efficiently manage content and achieve data interconnectivity in a complex website ecosystem is the key to improving operational efficiency.AnQiCMS (AnQiCMS) leverages its powerful multi-site management capabilities to provide us with such possibilities.Today, let's delve deeply into a very practical scenario in multi-site operations: how to make use ofcategoryListLabel, elegantly calling the classification data under other sites.

AnQi CMS multi-site management:categoryListIn-depth analysis of label cross-site classification data calling

AnQi CMS, this is a lightweight content management system developed based on the Go language, one of its core highlights is the excellent support for multiple sites.It allows us to manage multiple independent websites within a single system, whether it's a brand official website, product special page, or content distribution site, we can achieve unified background and independent operation.This architecture not only reduces the operation and maintenance cost, but also, it provides a solid foundation for cross-site data sharing and integration.

Under a multi-site scenario, we often encounter such needs: the main site needs to display a certain product category of the sub-site, or a general navigation needs to aggregate service categories from different sites.This is when the template tag system of Anqi CMS becomes especially powerful.

Unveiling the core of cross-site data calling:siteIdParameter

The template tag design of AnQi CMS is very flexible, most of the content-related tags are built with a name ofsiteIdThe parameter. This is the 'magic key' for cross-site data calls.

In the Anqi CMS backend, when we create or manage multiple sites, each site will have a unique identifier ID.Generally, this ID can be viewed in the multi-site management list.By default, all template tags automatically retrieve data from the current visited site, but once we explicitly passsiteIdThe parameter specifies the ID of the target site, and the tag will 'obey the command', turning to retrieve the required data from that specified site.

This means, even if you are editing the template of site A, as long as you know the site B'ssiteId, you can easily display the content of site B on site A.

categoryListTag: Navigate between sites and categories

categoryListThe tag is the core tag used to obtain the category list in AnQi CMS. Its basic usage is very intuitive, for example, to get all the top-level categories of the model with ID 1 under the current site, we can write it as:

{% categoryList categories with moduleId="1" parentId="0" %}
    <ul>
        {% for item in categories %}
            <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
        {% endfor %}
    </ul>
{% endcategoryList %}

Now, if our goal is to obtainother sites(assuming itssiteIdWith2) under, the model ID for1we only need to in thecategoryListadd in thesiteIdJust set the parameters:

{# 假设我们正在站点A的模板中,要调用站点B(siteId为2)的分类数据 #}
{% categoryList externalCategories with moduleId="1" parentId="0" siteId="2" %}
    <p>来自站点B的分类:</p>
    <ul>
        {% for item in externalCategories %}
            <li>
                {# 这里展示的是站点B分类的标题和链接,安企CMS会自动生成正确的跨站点链接 #}
                <a href="{{ item.Link }}">{{ item.Title }}</a>
            </li>
        {% endfor %}
    </ul>
{% endcategoryList %}

In this code block:

  • externalCategoriesIs a variable defined in the template, used to store the category list obtained from an external site.
  • moduleId="1"Specifies the category under the article model we want to retrieve (usually model ID 1).
  • parentId="0"We only get the top-level categories, not the subcategories.
  • siteId="2"That is the key! It clearly tellscategoryListthe tag, gositeIdWith2to search for category data in the site database.

In this way, we can flexibly obtain and display the classification information of other site templates on any site.It is as easy to build a unified product center as it is to compile corporate news.

Practical scenarios and advantages

UtilizesiteIdCall category data from other sites, which can bring many operational conveniences:

  1. Unified navigation experience:You can integrate the core categories of the child site into the navigation bar of the main site, allowing users to browse all related content through a single entry.
  2. Content aggregation and distribution:The main site can act as a content aggregator, displaying the category directories of multiple sub-sites (such as different product lines, different regional branches) uniformly, making it convenient for users to quickly locate.
  3. Reduce redundant construction:If certain category structures are shared across multiple sites, consider maintaining a core category on one site and then through other sitessiteIdCall it to avoid data redundancy and maintenance costs.
  4. Flexible cross-site links:AnQiCMS is generatingitem.LinkIt will intelligently judge the site it belongs to, ensuring that the link points to the correct site and category page without any additional processing.

Operation Tips and Notes

While usingsiteIdWhen performing cross-site data calls, as an operations expert, we still need to pay attention to several details:

  • Specify the site ID:Be sure to clearly record each site in the multi-site management interface of the backgroundsiteIdas well as the corresponding site name to avoid confusion.
  • Performance consideration: Although AnQiCMS is developed based on Go language with excellent performance, frequent or large-scale cross-site data calls may still place additional burden on the server.It is recommended to control the amount of data called and optimize it in combination with the cache mechanism.
  • Data consistency:The cross-site call is real-time data. If the classification structure of the source site changes, the caller will immediately reflect it.This is usually an advantage, but if there are special requirements, it is necessary to ensure that the data update strategy of the source site is consistent with the expectations of the caller.
  • Permission management:AnQiCMS multi-site management usually has independent databases or data isolation, cross-site calls are based on system-level features of template tags, usually do not require additional permission configuration, but understanding the underlying logic helps to troubleshoot problems.

BysiteIdParameters, of Anqi CMS'scategoryListLabels are not only tools for displaying category lists, but also bridges that connect the content ecosystems of multiple sites.Master this skill, and you will be able to operate website content more efficiently and flexibly, building an interconnected group of sites.


Frequently Asked Questions (FAQ)

  1. How to determine the specifics of a sitesiteId?You can find the list of all sites created in the "Multi-site Management" feature of the Anqi CMS backend. Each site will have a corresponding ID identifier, usually visible in the site name or edit details page, which is what you need to use in the template.siteId.

  2. exceptcategoryListWhich tags support this?siteIdHow to call data from other sites?AnQi CMS to achieve more comprehensive cross-site data sharing, many core content tags are supported.siteIdParameters. For example, used to call articles or product lists.archiveList, to get a single page list of.pageList, even to get site system configuration information.systemand contact information.contactTags such as these all have.siteIdParameters, allowing you to flexibly share and call various types of data between sites.

  3. If I specifysiteIdWill my current site be affected if the target site does not exist or the target site fails?IfsiteIdThere is no or the target site cannot respond,categoryListThe tag usually returns an empty list, which means no category data will be displayed, rather than causing the current site to crash.The design of AnQiCMS will try to ensure the stability of the system as much as possible.However, to ensure **user experience, it is still recommended tositeIdthe accuracy and the normal operation of the target site.