Hello,
I currently have a KirbyTag that allows me to insert a snippet that takes the values from a structured YAML field, and converts its data into a table. Until now, my project has only needed one such table per page, so I hard coded in the specific field name (distances
) into my KirbyTag plugin. However, I now need the ability to pass the name of a different field to this plugin (but default to distances
if no value is provided).
Here’s my tag:
(distances: title: Optional title)
I’m envisaging the following being possible:
(distances: more_distances title: More distances)
Here is my current plugin:
return [
'attr' => [
'title'
],
'html' => function ($tag) {
return snippet('scope/distances', [
'title' => $tag->title(),
'distances' => $tag->parent()->distances()->yaml()
], true);
}
];
So, I need a way of being able to modify $tag->parent()->distances()->yaml()
where the distances()
part of the query can be replaced by the tags value.
TL;DR: I need to pass a KibryTag attribute into a field query. Is this possible?