How to query nested structure-field into multiselect-field

Sure @yatil. Based on my examples in the first post, I first built the route, which generates a JSON-File containing my wanted tags like this:

'pattern' => 'project-filter-tags.json',
'action' => function () {
	$tags = array();
	foreach (site()->visit(site()->index()-> ... ->toString(), 'de')->filterCategories()->toStructure() as $filterCategory) {
		foreach ($filterCategory->filterTags()->toStructure() as $filterTag) {
			$tagGerman = $filterTag->filterTagGerman()->toString();
			$tagEnglish = $filterTag->filterTagEnglish()->toString();
			$tags[$tagEnglish] = $tagGerman;
		}
	}
	return response::json($tags);
}

Then I changed my multiselect-field in the blueprint to query this JSON-file like this:

projectTags:
  label: Tags
  type: multiselect
  translate: false
  options: api
  api: 
    url: "{{ site.url('de') }}/project-filter-tags.json"
    text: "{{ item }}"
    value: '"{{ item.key }}":"{{ item }}"'

I have a two-language-setup (de/en), which makes the whole thing a little special. As you probably see, I force the editor to input both language-versions of the tags in the german panel-version. Therefore I locked the source-structure-field and the target multiselect-field in the english panel-version.

1 Like