Mastering multi-site navigation: AnQiCMSnavListwith the tag andsiteIdParameter in-depth analysis

In today's complex and changing network environment, many enterprises and content operators are no longer satisfied with the operation of a single site.Brand extension, regional station, independent product line display, all of which have led to the demand for multi-site management.AnQiCMS (AnQiCMS) is a system designed specifically for enterprise-level content management, deeply understanding this field, and its powerful multi-site management function is born to solve this pain point.navListwith the tag andsiteIdParameter, to achieve flexible cross-site navigation calls.

One of the core strengths of AnQiCMS is its powerful multi-site management capability.It allows users to create and independently manage multiple websites under the same system architecture, each site can have its own content, templates, settings, and even language packs.This greatly simplifies the complexity of multi-brand or multi-regional operations, reduces repetitive work, and promotes data sharing and resource integration across sites.

Get to knownavListTag: the cornerstone of site navigation

In the template system of AnQiCMS,navListTags are the core tools for building navigation menus.It is responsible for extracting predefined navigation data from the background and providing it to the front-end template in an iterable list form.navListCan all胜任.

Generally, we would directly use the template of the current sitenavListtags to display the navigation of the site, for example:

{% navList navs %}
    <ul class="main-navigation">
        {% for item in navs %}
            <li class="{% if item.IsCurrent %}active{% endif %}">
                <a href="{{ item.Link }}">{{ item.Title }}</a>
                {% if item.NavList %}
                    <dl class="sub-navigation">
                        {% for sub_item in item.NavList %}
                            <dd><a href="{{ sub_item.Link }}">{{ sub_item.Title }}</a></dd>
                        {% endfor %}
                    </dl>
                {% endif %}
            </li>
        {% endfor %}
    </ul>
{% endnavList %}

This code will dynamically generate a menu based on the navigation category configured in the current site backend "Navigation Settings" (defaulting to the "Default Navigation" with ID 1). But if our goal is to callAnother siteWhere is the navigation? At this time,siteIdThe parameters come into play.

siteIdParameters: The magic key to unlock cross-site navigation calls

Now, let's delve deeper.siteIdA parameter that is exactly the magic key for cross-site navigation calls. In AnQiCMS, each independent site created through the "Multi-site Management" feature is assigned a uniquesiteId. ThissiteIdIs the digital identifier of the site, like the ID number of each website.

navListTags provide asiteIdParameters allow you to explicitly specify which site's navigation data you want to obtain. This means that regardless of which site you are currently on, as long as you know the target site'ssiteIdIt can easily pull and display its navigation menu.This is particularly useful for building a unified brand portal, sharing global footer navigation, or creating convenient jump links between related sites.

For example, suppose your main site (siteIdWith1) needs to display your sub-brand site B (siteIdWith2) specific navigation menu (assuming its navigation category ID is 3, named "Product Center"). You can write the code like this in the main station template:

{% comment %} 假设当前站点是站点A(siteId为1),我们想调用站点B(siteId为2)的“产品中心”导航 {% endcomment %}
<div class="site-b-product-nav">
    <h3>探索我们的产品</h3>
    {% navList siteB_products with typeId="3" siteId="2" %}
        <ul>
            {% for item in siteB_products %}
                <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
            {% endfor %}
        </ul>
    {% endnavList %}
</div>

In this code block,siteId="2"Accurately tell AnQiCMS to gositeIdWith2and find the navigation data on that site.typeId="3"Then further filter the navigation categories of the specific ID 3 under the site.In this way, even if the visitor is browsing the main site, they can clearly see the product navigation of the sub-brand site and click to jump, greatly enhancing the user experience and the interconnection between sites.

Application scenarios and operation points

  1. ObtainsiteId:To usesiteIdParameters, first you need to know the target site'ssiteIdThis information can be found in the 'Multi-Site Management' module of the AnQiCMS backend. Each site's list item will clearly display its unique number.IDThis is what we need to use in the templatesiteId.

  2. Build a unified global footer/header:Many companies want all sub-sites to have a unified footer that includes company information, privacy policies, and links to major product lines. By combining in the public template (such asbase.html)navListandsiteIdYou can call these global navigation from a central management site to ensure the synchronization and consistency of content across all sub-sites.

    {% comment %} 从主站点(siteId为1)获取全局底部导航(typeId为2) {% endcomment %}
    <footer class="global-footer">
        {% navList global_footer_nav with typeId="2" siteId="1" %}
            <ul class="footer-links">
                {% for item in global_footer_nav %}
                    <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
                {% endfor %}
            </ul>
        {% endnavList %}
        <p>&copy; {% now "2006" %} {{ system.SiteName }} All Rights Reserved.</p>
    </footer>
    
  3. Nested multi-site navigation: navListthe tags returned byitemThe object includes:NavListProperty, can be used to handle secondary even multi-level navigation. When combinedsiteIdWhen in use, you can build complex cross-site navigation structures, such as displaying another site's category list in a dropdown menu on a site, or even its popular articles.

    {% comment %} 在当前站点的导航中,嵌套显示另一个站点(siteId为3)的某个分类下的产品列表 {% endcomment %}
    {% navList current_site_nav with typeId="1" %}
        <ul>
            {% for item in current_site_nav %}
                <li>
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                    {% if item.Title == "我们的合作伙伴" %} {% comment %} 假设通过标题匹配一个特定菜单项 {% endcomment %}
                        <ul class="partner-products">
                            {% archiveList partner_products with type="list" siteId="3" categoryId="10" limit="5" %} {% comment %} 调用siteId为3的站点的分类ID为10的产品 {% endcomment %}
                                {% for product in partner_products %}
                                    <li><a href="{{ product.Link }}">{{ product.Title }}</a></li>
                                {% endfor %}
                            {% endarchiveList %}
                        </ul>
                    {% endif %}
                </li>
            {% endfor %}
        </ul>
    {% endnavList %}
    

    The example mentioned although integratedarchiveListBut its idea is the same, both are throughsiteIdto implement cross-site data calls.

Summary and prospects

BynavListwith the tag andsiteIdThe parameter's