I’m trying to set up some basic categorisation and filtering for the blog on a client site. I have the YML all set up in the articles blueprint:
articlecategories:
label: Article Categories
type: multiselect
min: 1
options:
mresearch: Market Research
busdev: Business Development Services
corsoc: Corporate Social Responsibility
default: mresearch
I have then used the blueprint() method to display the long text label based on the value stored e.g. “Market Research” when “mresearch” is in the article.txt file.
However, when multiple categories are selected for an article, I simply get the string of the comma-separated values, e.g. mresearch, busdev
I’m sorry if this is a simple fix, but I can’t workout where or how to start processing a string that contains multiple values and then displaying them correctly. It’s been a while since I’ve done much PHP or Kirby so I’m struggling a little.
Hey @texnixe - that was what I needed. Sorry about the lack of context - I simply wanted to display the category for each post/article on the posts page. I’ll turn each one of those category labels into a link for filtering the blog by category, but this first step was hurting my brain a bit.
I’ve ended up with the following (which I will now add formatting and HTML to).
That’s right, internally the split() field method uses Str::split() from the toolkit which in turn uses explode() internally, but also does some trimming. And it’s much more comfortable to call the field method on the field object, instead of