In a multi-site AnQiCMS environment,splitAre there any special considerations when the filter processes data from different sites?
Under the multi-site management capability of AnQiCMS, we often need to display content and handle data between different sites.splitThe filter acts as a fundamental and powerful string processing tool in the template engine and is naturally used frequently. Many people may be curious about what like when they first encounter a multi-site environment.splitDoes such a general filter have some special design or limitations when processing data from different sites.
First, let's briefly review.splitThe core function of the filter. It is a string processing tool, mainly used to split a string into an array according to a specified delimiter (slice in Go language).No matter whether the delimiter exists in the string, it will return an array.If the delimiter is empty, it will even split the string into an array by each UTF-8 character.For example, you have a string"apple,banana,orange", usingsplit:","And you get["apple", "banana", "orange"]such an array.
AnQiCMS was designed with the need for multi-site management in mind, allowing users to create and independently manage multiple sites. Each site can have its own content, templates, and data. To achieve this, the system providessiteIdThis parameter is applied to many data acquisition tags such asarchiveList/categoryDetail/systemMeaning, to clearly specify which site to obtain data from. This means that when we use these tags to pull data from a specific site, these data all have clear site ownership.
Then,splitDoes the filter have special considerations in this multi-site environment?
In short,splitThe filter itself is not specifically designed for multi-site environments and does not exist eithersiteIdSuch a parameter. Its behavior is always uniform, that is, to simply split the input string.It does not care about the source site of this string extraction, nor does it have the ability to aggregate or distinguish data sources across sites.
The core point is,splitA filter is a tool for "manipulating data" rather than a tool for "retrieving data". When you use it in the AnQiCMS template,splitWhen a filter is applied, it processes the string data already available in the current template context. These strings may come from:
- The data of the current site:This is the most common case. If you do not specify it explicitly in the template.
siteIdAnd obtained data (such as directly accessing the article details of the current site), then passing a field in the article content (such as a comma-separated list of keywords) tosplitthen, is there still a place for filters?splitThis string will be processed directly from the current site. - By
siteIdData from other sites is obtained through parameters:If you obtain tags through some data, for example,{% archiveDetail archive with name="Content" siteId="2" %}) Clearly obtained the detailed content of an article from a site with ID 2 and passed one of the string fields tosplitthen, is there still a place for filters?splitThe filter will cut the string coming from site 2.
Therefore,splitThe 'special consideration' of the filter in the multi-site scenario is not a change in its own behavior, but its operation.data sourceIt will vary depending on the multi-site environment. As a template developer, you need to ensure that you pass tosplitThe string of the filter is exactly the data of the site you expect to process. This requires you to use AnQiCMS provided at the data acquisition stage.siteIdParameters, accurately locate the data of the required site.
This means in practice:
- When you expect
splitWhen processing a string of a specific site, you need to usearchiveList/system/contactLabels to obtain data throughsiteIdThe parameter explicitly specifies the data source. - If the same type of data at different sites may use different delimiters (for example, site A uses commas, and site B uses semicolons), then you need to consider this point when writing the template, and it may be necessary to use conditional judgments or different variables to handle it.
Fundamentally,splitThe filter maintains its purity as a general string processing tool in the multi-site environment of AnQiCMS.It focuses on the parsing of string content, while the management and specification of the data source are handed over to more advanced data acquisition tags.Such a design is clearly分工明确, making the overall system logic more clear.
Frequently Asked Questions (FAQ)
splitCan the filter directly aggregate data from multiple sites and split it?No.splitThe filter is a tool used to process a single string and does not have the functionality to aggregate data from multiple sites. If you need to process data from multiple sites, you must first use the one withsiteIdParameter data acquisition label (such asarchiveListorsystem) Retrieve data from each site one by one, and then pass the strings that need to be processed on each site separately tosplitfilter for cutting.If data stored at different sites of the same type (such as keyword lists) uses different delimiters,
splithow will the filter handle it?splitThe filter will only split according to the single delimiter you specify. If data from different sites uses different delimiters and you only specify one, then for data that uses other delimiters,splitMay not be cut correctly, or may return results not as expected.In this case, you need to add logical judgment to the template, dynamically select the correct delimiter based on the data source or site type, or ensure that all sites use a unified delimiter standard for similar data.I want to use
splitHow should I operate the filter that processes data from another site?You need to use the AnQiCMS template supported firstsiteIdParameter data retrieval tag, explicitly specifying from which remote site to retrieve data. For example, using{% archiveDetail remoteArchive with name="Keywords" siteId="2" %}Get the keyword string for the article of site ID 2. Once you get this string (for example, stored inremoteArchiveIn the variable), you can pass it as if it were any other stringsplitFilter:{% set keywordsArray = remoteArchive|split:"," %}Thus,splitThe filter will split the keyword string coming from site 2.