Good evening
I am trying to filter pages according to category of the articles in my blog.
This is the blueprint part:
category:
type: tags
required: true
translate: false
options:
- Learning
- News
- Updates
Blog articles are stored in content/2_blog . Hence I try to do
page('blog')->children()->filterBy('category', param('tag'), ',')) // param('tag') successfully works e.g. returns "news".
Just to confirm: when I do
page('blog')->children()
I got five pages in my collection:
object(Kirby\Cms\Pages)#452 (5)
At least one of which has the “category” “News” attached:
I must oversee something very basic but cannot.
Help?
Thanks
Andreas
“news” - so that should be okay, right?
Not when it is stored as News with a capital N in your content file
Absolutely true! Kirby and me have a Großschreibproblem
Thanks!
To prevent such issues, you can also do fancy things like this:
page('blog')->children()->filter(fn($child) => in_array(strtolower(param('tag')), array_map('strtolower', $child->category()->split(','));
That is very fancy, thank you Sonja - I solved it the easy way by using the text/value option in the tag field 
One quick question though @texnixe : how can I access the “text” of the option?
When I do
<?= $page->category() ?>
The value gets outputted.
So for example “news” (value) and not “News” (text).
Thanks
Andreas
I have seen that thanks but it only shows the value() method. I would need a text() method which seems not to exist and is also not documented. Meaning I want to fetch the “nice” display text, not the value used in the background. I tried using the blueprint but this has no relation to the page then.
It’s all there in that little recipe, but you have to read it to the end… And you need to go via the blueprint (if you don’t want to create a category map), because - if you look at your content file - that information is simply not there.
That is of course very true! So a combination of content file value + blueprint lookup it is, thanks!