Is it possible to mix hardcoded Options AND a query in a single tags field?
I need to merge something like this:
fields:
tags:
label: Tags
type: tags
options:
- Design
- Architecture
- Photography
with something like this:
fields:
category:
label: Category
type: tags
options: query
query: site.children.published
β¦ in a single field
Thank you
I canβt seem to find the relevant code for the tags field, that would help. Thank you
You could use a route and query that
1 Like
This reminds me of a similar challenge I faced a while ago - hereβs an adaptation of the solution I built based on the suggestions from this forum thread, based on creating a page method (or page model) plugin:
<?php
Kirby::plugin('my/pagemethods', [
'pageMethods' => [
'customTagQuery' => function() {
$customtags = ['hardcoded1','hardcoded2','hardcoded3'];
foreach ( site()->index()->pluck("tags", ",", true) as $tag )
$customtags[] = $tag;
return array_unique( $customtags );
},
]
]);
In your blueprint:
fields:
category:
label: Hardcoded and queried tags
type: tags
options: query
query:
fetch: page.customTagQuery
text: "{{ arrayItem.value }}"
value: "{{ arrayItem.value.slug }}"
This could likely still be improved upon, but maybe as a starting point? (I did a quick test run and it works in my test environment).
1 Like