As an experienced website operation expert, I am well aware that how to efficiently manage content and achieve data intercommunication in a complex website ecosystem is the key to improving operation efficiency.Auto CMS (AutoCMS) provides such possibilities with its powerful multi-site management capabilities.categoryListLabel, elegantly call other site's category data.
Anqi CMS multi-site management:categoryListIn-depth analysis of label cross-site category data call
Auto CMS, this lightweight content management system developed based on the Go language has one of its core highlights in its excellent support for multi-sites.It allows us to manage multiple independent websites within a single system, whether it's a brand official website, a product special page, or a content distribution site, all of which can achieve unified backend and independent operation.This architecture not only reduces operation and maintenance costs, but more importantly, it provides a solid foundation for data sharing and integration across sites.
Under multi-site scenarios, we often encounter such needs: the main site needs to display a product category of a child site, or a general navigation needs to aggregate service categories from different sites.This is where the template tag system of Anqi CMS really shows its strength.
Unveiling the core of cross-site data call:siteIdParameters
The template tag design of AnQi CMS is very flexible, most of the content-related tags are built in a name calledsiteIdThis parameter is the 'magic key' for cross-site data calls.
In the background of Anqi CMS, when we create or manage multiple sites, each site will have a unique identifier ID.usually, this ID can be viewed in the multi-site management list.siteIdThe parameter specifies the ID of the target site, and the tag will 'obey the instructions' and 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 site B'ssiteId, you can easily display the content of site B on site A.
categoryList标签:在多站点间穿梭的分类导航
categoryListLabels are the core tags used in AnQi CMS to obtain category lists. Their basic usage is very intuitive, for example, to get all top-level categories of the model with ID 1 under the current site, we can write it like this:
{% 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 it)siteIdresponse for2), the model ID is1we only need tocategoryListadd tags to itsiteIdthe 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:
externalCategoriesIt is a variable defined in the template, used to store the category list obtained from an external site.moduleId="1"It specifies the category under the article model we want to retrieve (usually model ID is 1).parentId="0"Represents that we only get the top-level categories and do not include subcategories.siteId="2"is the key point! It explicitly tellscategoryListthe tag, to gositeIdresponse for2search for category data in the site database.
Through this method, we can flexibly obtain and display the classification information of other sites in any site template.It becomes effortless to build a unified product center or compile corporate news.
useful scenarios and advantages
UtilizesiteIdCall classification data from other sites, which can bring many operating conveniences:
- Unified navigation experience:The core categories of the child sites can be integrated into the navigation bar of the main site, allowing users to browse all related content through a single entry.
- Content aggregation and distribution:The main site can act as a content aggregator, displaying unified category directories of multiple sub-sites (such as different product lines, different regional branches), which is convenient for users to quickly locate.
- Reduce redundant construction:If certain classification structures are shared among multiple sites, consider maintaining a core classification at one site and then through
siteIdMake the call, avoid data redundancy and maintenance costs. - Flexible cross-site links:AnQiCMS in generating
item.LinkWhen, it will intelligently determine the site it belongs to, ensuring that the link points to the correct site and category page, without additional processing.
Operational Tips and注意事项
When usingsiteIdWhen performing cross-site data calls, as an operations expert, we still need to pay attention to several details:
- Make it clear which site ID:Ensure that each site is clearly recorded in the multi-site management interface in the background
siteIdand its corresponding site name to avoid confusion. - Performance considerations:Although AnQiCMS is developed in Go language with excellent performance, frequent or large-scale cross-site data calls may still place additional burden on the server.Suggested to reasonably control the amount of data called and optimize it with caching mechanisms.
- Data consistency:The cross-site call is real-time data.If the classification structure of the source site changes, the caller will reflect it immediately.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 calling party.
- Permission management:AnQiCMS's multi-site management usually has an independent database or data isolation, cross-site calls are based on system-level features of template tags, usually no additional permission configuration is required, but understanding its underlying logic is helpful for troubleshooting.
PasssiteIdParameter, Anqi CMScategoryListLabels are not only display tools for category lists, but have also become bridges connecting 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 websites.
Common Questions (FAQ)
How to determine the specific site
siteId?You can find the list of all created sites 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.Except
categoryListWhat other tags are supported?siteIdHow to call data from other sites using parameters?AnQi CMS supports many core content tags for achieving more comprehensive cross-site data sharingsiteIdParameters. For example, used to call article or product lists.archiveList, to get a single page list.pageList, even to get site system configuration information.system, and contact information.contactSuch tags are equipped with.siteIdParameters, allowing you to flexibly share and call various types of data between sites.If I specify
siteIdDoes my current site get affected if the target site does not exist or encounters a failure?IfsiteIdDoes not exist or the target site cannot respond,categoryListLabels usually return an empty list, which means no category data will be displayed, rather than causing the current site to crash.The design of AnQiCMS will strive to ensure the stability of the system.siteIdaccuracy and the normal operation of the target site.