How to apply categories to a piece of content?

Hello everyone! I’m quite new to Kirby and need some help.

I’m working on a small blog-like site. In the panel, the user should be able to optionally associate a piece of content with one or more “themes”. Each theme should have an optional description.

My thinking is that it should be possible to allow the user to create new themes in the panel as discrete entities. Then when the user is creating / updating a piece of content they would have some sort of field in the panel to allow them to view the pre-defined themes and choose to apply one (or many) to that piece of content. But I can’t figure out how this might be achieved!

I hope this hasn’t been asked before - I couldn’t find anything about this use case here on the forum or in the docs. Any help would be very greatly appreciated!

I’m not sure what you mean by “themes” if we’re talking about a topic or themes in visual terms.

One possibility could be to have a Themes page populated with theme sub-pages and then use something like this https://github.com/olach/kirby-relationship to pick the theme associated to any given page.

Make sense?

If it’s really all predefined, you can also use a simple select field where you prepopulate all the possible “themes” in the blueprint.
In the field’s “help” property in the blueprint, you can point a url to a (static) page where you have previews of all themes.

This way it’s all centralised and managed via the blueprint (and 1 static page).

That’s also a possibility but he said…

My thinking is that it should be possible to allow the user to create new themes in the panel as discrete entities.

…so I guess he wants/needs the ability to create themes directly in the admin rather than messing with the blueprint.
But if I’m wrong than yes, yours is definitely another solution :slight_smile:

Hmmm, I misread that. And thinking about this now, I don’t know how you would upload CSS etc too to make the “style” work?

That’s why I said in my first reply that I’m not sure if he’s talking about themes in the sense of visual themes or themes as topics. The latter is pretty straightforward, the former not so much :wink:

I blame the heat :smiley::sweat_smile:

I hear you, it’s 34° here today :joy:

As for the topic of this post, the solution really depends on what kind of information @goldwing needs to attach to each theme. Guess we’ll wait to hear from him :wink:

Thanks for the replies guys! Hope you are OK in the heat…

Sorry, I think the choice of “themes” as a word is confusing here - but yes it’s meant as a topic/category rather than visual theme, which can be created directly in the admin.

One possibility could be to have a Themes page populated with theme sub-pages and then use something like this GitHub - olach/kirby-relationship: Sortable multiselect field for Kirby 2 CMS 2 to pick the theme associated to any given page.

Yes, there is already a Themes page so this would be ideal. I have been playing around with the following config for a simple select field:

category:
  label: Theme
  type: select
  options: query
  query:
    page: themes
    fetch: children
    value: '{{title}}'
    text: '{{title}}'

but the kirby-relationship field looks very nice!

Thank you both!

A select field only allows you to add a single category, so the relatioship plugin or a multiselect field would be better options indeed. If you dont want to create pages for the topics but rather use a structure field, this would work with the relationship field as well, I think.