What I’d like to achieve is a global source for tags. I read through the docs and found the following query.
query: site.index.pluck("tags", ",", true)
I tried this query referencing another tag field which gave me the available tags from that field. So I set up a global tag field within my site blueprint and thought that I might be able to add the above query to every tag field, referencing the field name of this global tag field (siteTags).
Somehow my plan doesn’t work, though. I tried both with and without providing options in the global field. What I’m after is consistency with my tags throughout the site.
Is this even possible, or am I forgetting something? I’m guessing I would maybe have to alter the query, but don’t know in what direction.
label: Project Tag
label: Tag Name
label: Tag Identifier
Wondering, is there a way to to make a widget that not only querys/fetches tags and accepts those options but also allows you to make new tags on the fly, that then get added to the global tag list in site.txt?
Basically, combining the default behaviour of the tags field with the query option, so that you have the best of both worlds: no dublicate tags that can be queried and the possibility to add tags from anywhere in the site to a globally accessible list.
I guess it’s easier if you have tags are just text strings. In my case they also have a color associated with each tag.
Similar to how Notion or GitHub issues handles it. (I’d link an image but somehow it doesnt work.)
Yes, you could update the structure field in site.txt via a page.update:after hook. Inside your hook, you check if the tags used in the current page are already present in the structure, and if not, add them.
However, I wonder if this is really the best approach and if it wouldn’t make more sense to merge global_tags with tags used in your project pages?
I wonder how this is supposed to work with the color option. I mean, the tags field allows you to either limit the options to your query, or to also let users add their own tags (which is the default behavior).
So a new tag added to a tags field is just a simple string. How does this make sense in the context of your structure field of global tags? You would only be able to fill the tag field in that structure, but how about the identifier (if it is not redundant), or a color option?
Ah sorry, yeah structured fields are a bonus right now
I’m just wondering if there is a way to: instead of either/or, have both options simultaneously:
query a basic string from the global list
and if your query is not in the global list you can add it to it as a new tag
And I guess for querying a structured item you would need some kind of custom wizard that lets you choose colors or any other option in that tag with a context menu. (That’s how GitHub issues and tags in Notion Tables do it—even if you don’t define a color it just gets randomly generated).
But even just being able to query and add a basic string/tag at the same time would make it already easier for editors so they don’t have to leave the current page go into the settings and add tags there.
Still, do you think you can point me into a direction for how to go about querying and adding structured items to a global list from within another page, for example a tag with an associated color, or let’s say a name with an associated external url.
Adding and querying tags with colors to/from a globally accessible list is possible in Notion and GitHub issues. I’m a little lost in what to even search for in the docs. I’d assume a custom field or blueprint, or page methods as you describe here?:
Or maybe this is not possible and I’m missing something fundmental about Kirby here?
That would only work if you use structure fields for both, i.e. in your central location, and in the pages themselves, but there is a caveat: Say in your structure field in the specific pages you have two fields:
So if you select a tag in the first field, you wouldn’t be able to also fetch the associated color value from the same tag on the fly, at least not without a custom implementation. It would work for adding a new tag-color pair, but not for the use case selecting from global.