If my AnQi CMS is a multi-site deployment, how to use the `moduleDetail` tag to retrieve the content model data of other sites?

Calendar 81

AnQi CMS is an enterprise-level content management system designed specifically for small and medium-sized enterprises, self-media, and multi-site management, and its multi-site management capability is undoubtedly one of its core highlights.In daily operations, we often encounter such a scenario: we hope to display certain information of the child site on the main site, or to carry out cross-references of content or data models between different sites.Today, let's delve into a specific and practical scenario - how to usemoduleDetailTag to get the content model data of other sites.

The underlying logic of Anqi CMS multi-site deployment

Before delving into the technical details, let's briefly understand the intricacies of the Anqi CMS multi-site deployment.AnQi CMS is not just running multiple systems independently, but rather, it distinguishes different sites through independent databases and configuration files based on a core code basis.This means that although each site has its independent backend management interface, content data, and front-end display, they share the same program core.This design makes cross-site data referencing possible, greatly enhancing management efficiency and content reuse.Each child site created in the background "Multi-site Management" will be assigned a uniquesiteIdThis is the key identifier for cross-site data operations.

moduleDetailLabel: A tool for obtaining content models

moduleDetailThe tag plays a role in the Anqi CMS template system in obtaining detailed information about a specific content model.It can help us retrieve the ID, name, link, table name, and even custom fields of a certain content model.In a single-site environment,moduleDetailIt will default to fetching the content model information under the current site. But when it comes to multiple sites, its strength is highlighted by an additional parameter - that issiteId.

By usingmoduleDetailSpecify the tagsiteIdParameter, you can explicitly tell the system which site's content model you want to query. Combinedid(Content Model ID) ortoken(Content model URL alias) parameter, you can accurately locate the specific content model on the target site and extract its related data.

moduleDetailThe tag supports getting the following core fields, which are very useful for displaying an overview of the content model:

  • Id: The unique identifier of the content model.
  • Title: The Chinese title or display name of the content model.
  • Name: The English name or URL alias of the content model, often used in pseudo-static paths.
  • Keywords: The keywords set for the content model.
  • Description: A brief description of the content model.
  • Link: The homepage link of the content model.
  • TableName: The corresponding data table name of the content model in the database.

Practice exercise: Retrieve product model information of the child site

Suppose you have a main site (Site A,siteIdas 1) and a child site specifically for displaying products (Site B,siteIdIn order to 2). Now, you want to display the name and link of the "product" content model from Site B on a page in the main site (Site A).

Step 1: Determine the target site.siteIdand content model information

You need to log in to the AnqiCMS backend management interface, go to "Multi-site Management" to view the child site B'ssiteId. Assuming that Site B'ssiteIdIs2.

Next, go to the backend of Site B, enter "Content Management" -> "Content Model", find the "Product" content model. Click edit to view its "Model ID" (for example:3Or "URL alias" (e.g.,)product). Here we use ID to demonstrate.

Step two: Build in the main site template.moduleDetailTag

Now, we return to the template file of the main site (Site A). You can use it at any location where you want to display this information.moduleDetail.

{# 在主站点(Site A)的模板中,获取子站点(Site B,siteId=2)的“产品”内容模型(ID=3)的标题 #}
{% moduleDetail productModelTitle with name="Title" id="3" siteId="2" %}
<p>子站点产品模型的标题是:{{ productModelTitle }}</p>

{# 获取子站点(Site B)的“产品”内容模型(ID=3)的链接 #}
{% moduleDetail productModelLink with name="Link" id="3" siteId="2" %}
<p>子站点产品模型的链接是:<a href="{{ productModelLink }}">{{ productModelLink }}</a></p>

{# 更全面的方法:获取整个内容模型对象,然后从对象中提取多个字段 #}
{% moduleDetail fullProductModel with id="3" siteId="2" %}
<div class="other-site-product-model-info">
    <h3>来自其他站点的产品模型信息</h3>
    <p>模型ID:{{ fullProductModel.Id }}</p>
    <p>模型名称:{{ fullProductModel.Title }}</p>
    <p>模型URL别名:{{ fullProductModel.Name }}</p>
    <p>模型表名:{{ fullProductModel.TableName }}</p>
    <p>模型首页:<a href="{{ fullProductModel.Link }}" target="_blank">{{ fullProductModel.Link }}</a></p>
    <p>模型描述:{{ fullProductModel.Description }}</p>
</div>

In this way, the main site (Site A) can successfully obtain and display the detailed information of the product content model in the sub-site (Site B).This cross-site call feature provides great flexibility for your multi-site operation, allowing you to easily share and display key data across different sites according to your business needs.

Further Thinking:siteIdUniversality of Parameters

It is worth mentioning,siteIdThe parameter is notmoduleDetailTags are unique. In the Anqi CMS template tag system, many tags related to content, categories, tags, and other data, such asarchiveList(Document list),categoryList(Category list),tagList(Tag list) and others, are supportedsiteIdThis means that as long as you know the target site's parameters.siteIdYou can flexibly call and display various content data from other sites, realizing the true cross-site content integration and operation.This design concept greatly simplifies the complexity of data intercommunication among multiple sites, making the implementation of content operation strategies more efficient and convenient.


Frequently Asked Questions (FAQ)

  1. Ask: How do I know about my other sites?siteIdare?Answer: You can log in to the backend management interface of your Anqi CMS main site and navigate to the "Multi-site Management" menu. There, you will see a list of all created child sites, each clearly marked with the correspondingsiteIdThis ID is a unique identifier automatically assigned by the system.

  2. Question: Can I use parameters to get content from other sites?siteIdCan I use parameters to get content from other sites?Answer: Of course you can!siteIdThe parameter is a general mechanism implemented by Anqi CMS for cross-site data access. In addition,moduleDetailtags, you can also use inarchiveList(Retrieve document list) ,archiveDetail(Get document details),categoryList(Get category list),categoryDetail(Retrieve category details) ,tagList(Using multiple core content tags such as)siteIdParameters to call and display the corresponding content of other sites on the current site.

  3. Question: If the target site'sidortoken(URL alias) Will my call fail if it changes in the future? Is there a more stable way to specify the content model?Answer: Use the content model.idIt is accurate, but if the ID may indeed change, usetoken(URL alias) would be a safer choice, as URL aliases are usually more stable and more readable. For example, you can usetoken="product"Insteadid="3"Specify the product model. In practice, it is recommended to choose based on the management specifications and stability of your site's content model.idortoken.

Related articles

How to retrieve information about a specific model through the content model's URL alias (`token`)?

## How to skillfully use AnQiCMS content model URL alias (`token`): The wisdom of accurately obtaining information As an experienced website operations expert, I am well aware of the importance of an efficient and customizable content management system for enterprise websites and content operation teams.AnQiCMS with its efficient architecture in Go language and versatile functions is gradually becoming a powerful assistant for many operators.In daily content management, we not only strive for the quality presentation of content, but also need efficient data access and management. Today

2025-11-07

I want to display the Chinese title of the current content model in the template, which field of the `moduleDetail` tag should be used??

As an experienced website operations expert, I know that the flexible use of templates in AnQiCMS (AnQiCMS) is the key to improving website operation efficiency and user experience.When faced with the need to dynamically display content model information, such as the Chinese title of the current content model, choosing the correct label field is particularly important.Today, let's delve deeply into how to accurately display the Chinese title of the current content model in the Anqi CMS template.

2025-11-07

The `moduleDetail` tag's `name` parameter can be used to retrieve which specific fields of the model details?

As an experienced website operations expert, I am well aware that how to efficiently use the built-in tags in a rich-featured content management system like AnQiCMS to drive content display and management is the key to improving operational efficiency.Today, let's delve into the `moduleDetail` tag and its `name` parameter, which can help us accurately obtain the specific fields of the content model, providing strong support for the flexibility and maintainability of the website.

2025-11-07

In AnQi CMS, what parameters does the `moduleDetail` tag support to specify the model to be retrieved?

As an experienced website operations expert, I know that accurately calling and displaying content model details in a flexible and efficient content management system like AnQiCMS is the key to building a functional and user-friendly website.The Anqi CMS, with its powerful custom content model capabilities, allows us to flexibly build data structures according to various business needs (whether it is articles, products, or event pages).Today, let's delve deeper into the process of template development using AnQiCMS, `moduleDetail`

2025-11-07

What is the difference and usage of the `Title` and `Name` fields in the content model in practice?

In the daily operation of AnQiCMS, we often encounter content models and their fields.Among the field names "Title" and "Name", which seem similar, there are completely different responsibilities in practical application.As an experienced website operations expert, I fully understand the importance of understanding these subtle differences for efficient content management, optimizing website structure, and improving user experience.

2025-11-07

How to retrieve the database table name (`TableName`) of the content model in a template for a custom query?

As an experienced website operations expert, I deeply understand the powerful capabilities brought by the flexible content model in AnQiCMS through my practice.Many times, we not only need to display the content itself, but also need to drive deeper page logic or style based on the type of content.Today, let's delve deeply into a seemingly minor but crucial feature: how to obtain the database table name (TableName) of the content model in AnQiCMS templates, thus achieving more refined custom control.--- ###

2025-11-07

Does the `moduleDetail` tag support direct retrieval of custom field values defined in the content model, and if so, how do you call it?

As an experienced website operations expert, I know the importance of a flexible content model and convenient template calls for a modern CMS.AnQiCMS (AnQiCMS) performs well in this aspect, its powerful template tag system makes content presentation flexible and efficient.Today, let's delve deeply into a question that concerns everyone: Does the `moduleDetail` tag support direct retrieval of custom field values defined in the content model?How can it be called if it can? Firstly, let's clarify the division of responsibilities of different tags in the Anqi CMS

2025-11-07

How to determine if the current page belongs to a specific content model (such as 'article model'), and display different content accordingly?

As an experienced website operations expert, I know that flexible content display is crucial for the operational efficiency and user experience of a website.In a powerful content management system like AnQiCMS, understanding how to display differentiated content based on different content models is a key step in achieving refined operation.Today, let's delve deeply into this topic and reveal how AnQiCMS can help us easily achieve this goal.

2025-11-07