Query from multiple tag fields

Is it possible to pluck tags from multiple fields – or from all tag fields for that matter?

category1:
  label: Category 1
  type: tags
  options: query
  query: page.siblings.pluck("category1,category2", ",", true)
  
category2:
  label: Category 2
  type: tags
  options: query
  query: page.siblings.pluck("category1,category2", ",", true)

I know this does not work, just to illustrate my question :wink:

THX!

You could create a custom page method/model that plucks all tags from field 1, then from field two etc. and then merges the arrays. Then query that method.

Ok, thought it was probably possible with the query language only.

Thanks, I’ll try to work that out!

I don’t think so, because pluck() only accepts a single field.

Some code:

$allTags = [];
$fields = ['tags', 'categories', 'whatever'];
foreach ($fields as $field) {
  $tags = page('somepage')->children()->pluck($field,',', true);
  $allTags = array_merge($allTags, $tags);
}
dump(array_unique($allTags));

Something like this then wrapped in a method, or create a custom collection.

Cool! Thanks @texnixe!