How to obtain the basic configuration information of a specified site when operating multi-site?

Calendar 👁️ 68

AnQiCMS (AnQiCMS) provides great convenience to operators with its excellent multi-site management capabilities.Whether you have multiple brand sites under your company, regional sub-sites, or need to build independent content portals for different business lines, AnQiCMS can efficiently manage them in a unified backend.However, in actual operation, you may encounter such a scenario: in a site template, it is necessary to obtain the basic configuration information of another site, such as its website name, logo, URL, or contact information.This is when the powerful system tags of Anqi CMS come into play.

Unlock multi-site configuration information: The Art of AnQiCMS System Tags

The template engine of AnQiCMS is designed to be very flexible, it can not only obtain various data from the current page, but also through the introductionsiteIdParameters, break the data barriers between sites, allowing you to easily 'peek' into the basic configuration information of other sites in any site template.This is like having a dedicated information officer for each of your sites, always ready to follow your command.

1. Core weapon:systemwith the tag andsiteIdParameter

To obtain the basic configuration information of the specified site, we first need to summon the most core system setting tag of AnQiCMS -system. This tag is used to retrieve the global configuration of a website, such as the website name, logo, filing number, etc. Usually, when you use it in a template,{% system with name="SiteName" %}When such a label is used, it will automatically retrieve the name of the current site.

But when you need to getAnother sitethe name of the site, just usesystemadd in thesiteIdparameter. ThissiteIdIt is the unique ID corresponding to each site in the "Multi-site Management" feature of the Anqi CMS backend. You can view the unique ID of each site in the multi-site list on the backend.siteId.

For example, assume you have onesiteIdWith2sub-site, whose website name is 'AnQi Mall', and you want to display it at some location on the main site:

{# 获取siteId为2的站点的网站名称 #}
{% system subSiteName with name="SiteName" siteId="2" %}
<div>欢迎访问我们的兄弟站点:{{ subSiteName }}</div>

By this means,subSiteNamea variable will be storedsiteIdWith2The name of the site. You can replace it according to your actual needs.siteIdTo get the configuration of different sites, you can use the value.

In addition to the site name,systemTags also support getting other rich configuration information, such as:

  • Website Logo (SiteLogo):
    
    {% system subSiteLogo with name="SiteLogo" siteId="2" %}
    <img src="{{ subSiteLogo }}" alt="安企商城Logo" />
    
  • The home page address (BaseUrl):
    
    {% system subSiteUrl with name="BaseUrl" siteId="2" %}
    <a href="{{ subSiteUrl }}">前往安企商城</a>
    
  • Website filing number (SiteIcp), Copyright information (SiteCopyright), Custom parametersThey can all be changed in the same way, just need to modifynameto get the value of the parameter.

2. Extended Applications:contact/tdkas well asdiyTag

siteIdThe power of the parameter is far more than just that.systemLabel. Many other basic information labels in AnQi CMS also support itsiteId, allowing you to obtain the detailed configuration of the specified site more comprehensively.

  • Get the contact information of the specified site (contactLabel):Assuming you want to obtainsiteIdWith3the contact phone number of the site:

    {% contact subSitePhone with name="Cellphone" siteId="3" %}
    <div>如需帮助,请拨打:{{ subSitePhone }}</div>
    

    You can also obtain its contact address, email, WeChat, etc., just by replacing thenameparameter withAddress/Email/WechatLeave the corresponding fields unchanged.

  • Get the SEO configuration of the specified site (tdkLabel):It is very useful to obtain the title, keywords, and description of a specified site when performing cross-site SEO strategies or data presentation:

    {% tdk subSiteTitle with name="Title" siteId="2" %}
    <meta name="other-site-title" content="{{ subSiteTitle }}">
    

    Similarly, replacenameparameters forKeywordsorDescriptionJust do it.

  • Get custom configuration (diyLabel):If you have customized some parameters in the background "Global Function Settings" of a site, such as a specific "Announcement Link", you can also access it bydiyTags andsiteIdto get:

    {% diy subSiteNoticeLink with name="NoticeLink" siteId="2" %}
    {% if subSiteNoticeLink %}
    <div><a href="{{ subSiteNoticeLink }}">查看安企商城的最新公告</a></div>
    {% endif %}
    

The flexible application of these tags makes it easy to call data during multi-site operations, greatly enhancing the efficiency of template development and the ability to integrate data.

Practical suggestions and precautions

  1. clearsiteId:While usingsiteIdBefore the parameter, please make sure to confirm the site information you need to obtain in the "Multi-site Management" of the AnQiCMS backend.siteIdThis is the premise of accurate data calling.
  2. Reasonable planning:Even though cross-site data calls are convenient, it is recommended that you plan according to your actual needs.Avoid calling a large amount of complex data from other sites too frequently on a single page, as this may have a subtle impact on page loading performance (though AnQiCMS is based on Go language and performs excellently, good habits are still crucial).
  3. Test verification:In the process of template development, you can first print out the variables obtained, such as{{ subSiteName | dump }}, to verify that the data is correctly obtained, which helps to quickly troubleshoot issues.

AnQiCMS system tag matchingsiteIdParameters, it has given wings to your multi-site content operation. From now on, no matter where the data is located on any site, you can easily handle it and achieve richer and smarter content display strategies.


Frequently Asked Questions (FAQ)

Q1: How do I find a specific site?siteId?A1: You can log in to the AnQiCMS backend and go to the \siteId. You can also set the ID automatically when creating a new site.

Q2: Can I set up through basic configuration information?siteIdGet the list of articles, classification information, and other contents from other sites?A2: Absolutely. Many content tags like AnQiCMS'sarchiveList(Document list),categoryList(Category list),pageListEven (single-page list) eventagList(Tag list) and also supportsiteIdParameters. This means you can be very flexible in displaying specific content from other sites on any site, for example, by aggregating and displaying the latest articles from all child sites on a portal site.

Q3: If I provided the wrongsiteId, or thatsiteIdthe corresponding site does not exist, will the template report an error?A3: Normally, the AnQiCMS template engine handles this situation in a friendly manner. IfsiteIdThe site does not exist or the site does not have the specific field value you are trying to retrieve. Tags usually return null or default values, which will not directly cause a template rendering error. This makes the template more robust in the face of missing data, but for accuracy, it is still recommended that you ensuresiteIdthe correctness.

Related articles

How to obtain and display the website's filing number and custom copyright information?

As an experienced website operations expert, I fully understand the importance of website compliance and brand information display for user trust and corporate image.AnQiCMS (AnQiCMS) provides powerful and flexible features in these aspects, allowing you to easily manage and display the filing number and custom copyright information of your website.Next, I will explain in detail how to implement these operations in AnQiCMS. --- ## How to obtain and display the record number and custom copyright information of a website?

2025-11-07

How to display the current website's name and Logo in Anqi CMS template?

As an experienced website operations expert, I am well aware of the importance of a website's name and logo in brand image and user recognition.In a powerful and flexible content management system like AnQiCMS, presenting these core brand elements in the website template not only enhances professionalism but also helps with search engine optimization (SEO).Today, I will give a detailed explanation of how to easily display the current website name and logo in AnQiCMS templates, making your brand shine in the eyes of users.--- ### AnQi CMS Template

2025-11-07

How to perform security filtering on the date string generated by the `stampToDate` tag to prevent XSS attacks?

As an experienced website operation expert, I am happy to give you a detailed explanation of how to ensure the security of the date string generated by the `stampToDate` tag in AnQiCMS, effectively preventing XSS attacks. --- ### Ensure Security: How to effectively prevent XSS attacks in the date string generated by the `stampToDate` tag in AnQiCMS In the template development of AnQiCMS, the `stampToDate` tag is a powerful helper for us to process timestamps and format them into readable date strings.

2025-11-07

What is the main difference between the `now` tag and the `stampToDate` tag in the time display in `tag-system.md`?

As an experienced website operations expert, I am well aware that how to flexibly and accurately display time information in a content management system is crucial for the vitality of website content and user experience.AnQiCMS (AnQiCMS) takes this point into full consideration in the design of template tags, providing various methods to handle time.Today, let's delve into two commonly used and easily confused tags - the `now` tag and the `stampToDate` tag, analyzing their main differences in time display.

2025-11-07

How to dynamically obtain the path of the static resources used by the current website template?

As an experienced website operations expert, I know how important efficiency and flexibility are in managing websites, especially content management systems (CMS).AnQiCMS as an enterprise-level content management system based on the Go language has fully considered these requirements from the very beginning, especially in terms of template and resource management, providing a powerful and elegant solution.Today, let's delve deeply into a very practical topic in template development: 'How to dynamically obtain the static resource path of the template currently used by the AnQiCMS website?'}]

2025-11-07

How to determine if a website is in a shutdown state and display user-friendly prompt information?

## The website operation 'shut down' maintains dignity: AnQi CMS helps you shut down gracefully and provide friendly prompts In the daily operation of the website, we will always encounter times when we need to temporarily 'shut down'.For reasons such as system upgrades, large-scale content adjustments, data migration, or for security maintenance, content filling and review before the launch of a new website, a proper shutdown process is crucial.This concerns not only the security and stability of the website's data, but also directly affects the user experience and the evaluation of the website by search engines.

2025-11-07

How to display the current year or a specific format of time in the template in real-time?

In website operation, the display of time information is ubiquitous, whether it is the current year in the copyright statement, the time of article publication, or the deadline of the event, dynamic and accurate time display is crucial for improving user experience and content timeliness. As an enterprise-level CMS dedicated to efficient content management, AnQiCMS (AnQiCMS) understands this need and therefore provides intuitive and powerful tags in the template system, allowing you to easily display the current year or a custom time format in the website template at any time.

2025-11-07

How to customize system-level parameters and flexibly call them in the front-end template?

## Mastering AnQi CMS: Flexible System-Level Parameter Customization and Efficient Front-End Template Calls As an experienced website operations expert, I fully understand the importance of a flexible and customizable content management system for corporate efficient operations.AnQiCMS (AnQiCMS) boasts a high-performance architecture based on the Go language and rich features, performing excellently in content publishing, multi-site management, and SEO optimization. Especially in terms of system parameter customization and invocation, it provides great convenience, allowing operators to easily handle all aspects of the website.

2025-11-07