AnQi CMS is an enterprise-level content management system specially designed for small and medium-sized enterprises, self-media, and multi-site management, and its multi-site management capabilities are undoubtedly one of the core highlights.In daily operations, we often encounter such scenarios: we hope to display certain information of child sites on the main site, or to perform cross-references of content or data models between different sites.moduleDetailRetrieve content model data from other sites.
The underlying logic of multi-site deployment for AnQi CMS.
Before delving into the technical details, let's briefly understand the intricacies of the multi-site deployment of Anqi CMS.AnQi CMS does not simply run multiple systems independently, but distinguishes different sites based on a core code base, independent databases, and configuration files.This means that, although each site has its independent backend management interface, content data, and frontend display, they share the same program kernel.This design makes cross-site data references possible, greatly enhancing management efficiency and content reusability.siteIdThis is the key identifier for cross-site data operations.
moduleDetailTag: A powerful tool for getting content models
moduleDetailTags play the role of obtaining detailed information of specific content models in the template system of AnQi CMS.It can help us retrieve the ID, name, link, table name, and even custom fields of a certain content model.moduleDetailIt will default to retrieving the content model information under the current site. However, its power becomes apparent when dealing with multiple sites, which is revealed through an additional parameter.siteId.
By setting amoduleDetaila tag specificationsiteIdParameter, you can explicitly tell the system which content model under which site you want to query. Combinedid(Content Model ID) ortokenParameter for the content model URL alias, allowing you to accurately locate a specific content model on the target site and extract its related data.
moduleDetailTag supports retrieving the following core fields, which are very useful for displaying an overview of the content model:
- Id: The unique identifier for the content model.
- TitleThe Chinese title or display name of the content model.
- NameThe English name or URL alias of the content model, often used in pseudo-static paths.
- KeywordsContent model setting keywords.
- DescriptionBrief description of the content model.
- LinkHome link of the content model.
- TableNameThe content model corresponds to the data table name in the database.
Practical Exercise: Retrieve product model information of the child site
Assuming you have a main site (Site A,siteIdFor 1) and a dedicated sub-site for displaying products (Site B,siteId[en]Now, you want to display the name and link of the "Product" content model from the child site (Site B) on a page of the main site (Site A).
First step: Determine the target site'ssiteIdand content model information
You need to log in to the admin interface of AnQi CMS, go to 'Multi-site Management' to view the child site B'ssiteIdAssuming the search results for Site B.siteIdYes2.
Next, go to the backend of Site B, enter "Content Management" -u003e "Content Model3)or “URL alias”(for example:)product)。Here, we use ID to illustrate.
Step 2: Build in the main site templatemoduleDetailtags
Now, let's return to the template file of the main site (Site A). You can use this information at any location you wish to display.moduleDetailLabel.
{# 在主站点(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>
By this means, the main site (Site A) can successfully obtain and display the detailed information of the "product" content model from the child site (Site B).This cross-site calling feature provides great flexibility for your multi-site operations, allowing you to easily share and display key data across different sites according to your business needs.
Extended Thinking:siteIdUniversality of Parameters
It is worth mentioning that,siteIdParameters are notmoduleDetailLabel-specific. In the template tag system of Anqi CMS, many tags related to content, categories, labels, and other data, such asarchiveList(Document List),categoryList(category list),tagList(label list), etc., all supportsiteIdThis means that as long as you know the target site'ssiteId
Common Questions (FAQ)
Question: How do I know the other sites of mine
siteIdWhat is it?Answer: You can log in to the backend management interface of your security CMS main site to navigate to the 'Multi-site Management' menu. There, you will see a list of all created child sites, each of which is clearly marked with its correspondingsiteIdThis ID is a unique identifier automatically assigned by the system.Question: Can I use parameters to get content from other sites in addition to the content model?
siteId?Answer: Of course you can!siteIdParameters are the general mechanism of Anqi CMS for cross-site data access. In addition tomoduleDetailtags, you can also inarchiveList(Get document list),archiveDetail(Get document details),categoryList(Get category list),categoryDetail(Obtain category details),tagListUsed in multiple core content tags such as (Obtain tag list),siteIdParameters to call and display the corresponding content of other sites at the current site.Ask: If the target site's
idortoken(URL alias) changes in the future, will my call fail? Is there a more secure way to specify the content model?Answer: Use the content model.idIs accurate, but if the ID may indeed change, usetoken[The alias URL] would be a more secure choice, as URL aliases are usually more stable and more readable. For example, you can usetoken="product"Instead ofid="3"Specify the product model. In actual operation, it is recommended to choose based on the management specifications of your site and the stability of the content model.idortoken.