In the multi-site AnQiCMS environment,splitDoes the filter handle data from different sites with special consideration?

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 basic and powerful string processing tool in the template engine and is naturally used frequently. Many people may be curious about howsplitWhether such a universal filter will have some special design or restrictions when handling data from different sites.

Firstly, 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 (slice in Go language) according to a specified delimiter.Whether the delimiter exists in the string or not, it will return an array.If the delimiter is empty, it will even split the string into an array by each UTF-8 character."apple,banana,orange"Usesplit:","Then we can 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 providessiteIdsuch parameters, applied to many data acquisition tags (such asarchiveList/categoryDetail/system[en]To specify which site to retrieve data from, as in “(etc.),” which makes it clear which site the data should be fetched from. This means that when we use these tags to pull data from a specific site, all the data has a clear site attribution.

So,splitDoes the filter have any special considerations in this multi-site environment?

In short,splitThe filter itself is not designed specifically for multi-site environments, nor does it existsiteIdSuch a parameter.Its behavior is always uniform, that is, it only performs cutting processing on the input string.It does not care about whether this string is extracted from data from which site, nor does it have the ability to aggregate or distinguish data sources across sites.

The essence lies in,splitA filter is a 'tool for manipulating data' rather than a 'tool for acquiring data'. When you use it in the AnQiCMS template,splitThe filter processes the string data that is already available in the current template context. This string data may come from:

  1. The data for the current site:This is the most common case. If you have not explicitly specified in the templatesiteIdWhile obtaining the data (for example, directly accessing the article details of the current site), then passing a certain field (such as a comma-separated list of keywords) from the article content.splitFilter, thensplitIt will directly process this string from the current site.
  2. PasssiteIdParameters from the data obtained from other sites:If you obtain a tag through some data (such as){% 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 its string fields.splitFilter, thensplitThe filter will split this string coming from site 2.

Therefore,splitThe 'special consideration' of the filter in multi-site scenarios is not a change in its own behavior, but in its operationsData sourcemay vary due to multi-site environments. As a template developer, you need to ensure that you pass insplitThe string of the filter is exactly the data from the site you expect to process. This requires you to use the AnQiCMS provided in the data acquisition stage.siteIdParameters such as these, accurately locate the data of the required site.

In actual operation, this means:

  • When you expectsplitWhen processing a string for a specific site, you need to usearchiveList/system/contactWhen fetching data with tags, the data source is specified through parameters.siteIdParameters explicitly specify the data source.
  • If the same type of data from different sites may use different delimiters (for example, site A uses commas, and site B uses semicolons), then you need to consider this when writing your template, and may need to use conditional judgment or different variables to handle it.

In essence,splitThe filter maintains its purity as a universal string processing tool in the multi-site environment of AnQiCMS.It focuses on parsing the string content, while the management of the data source and specification are handed over to more advanced data retrieval tags.Such a design has clear division of labor, making the overall logic of the system more clear.


Common Questions (FAQ)

  1. splitCan the filter directly aggregate and slice data from multiple sites?Cannot.splitThe filter is a tool used to process individual strings and does not have the functionality to aggregate data from multiple sites. If you need to process data from multiple sites, you need to use a filter withsiteIdParameter data retrieval label (such asarchiveListorsystem) Retrieve the data of each site one by one, and then pass the string that needs to be processed in each site separately tosplitthe filter for splitting.

  2. If the same type of data (such as a keyword list) stored at different sites uses different delimiters,splithow will the filter handle it? splitThe filter will only split by the single delimiter you specify for it. If data from different sites uses different delimiters and you only specify one, then for data that uses other delimiters,splitMay not cut correctly, or return results that do not meet expectations.In this case, you need to add logical judgment in the template, dynamically selecting the correct delimiter based on the data source or site type, or ensuring that similar data from all sites adhere to a unified delimiter standard.

  3. I want to usesplitHow should I operate the filter to process data obtained from another site?You need to use the AnQiCMS template first that supportssiteIdParameter data retrieval tag, explicitly specifying from which remote site to retrieve data. For example,{% archiveDetail remoteArchive with name="Keywords" siteId="2" %}Retrieve the keyword string for the article with site ID 2. Once you obtain this string (for example, stored inremoteArchiveIn a variable), you can pass it to any other string as you would processsplitFilter:{% set keywordsArray = remoteArchive|split:"," %}like this,splitand the filter will split the keyword string coming from site 2.