Filter menu – multi categories per project

Hello,
Congratulations for the new videos on Kirby’s youtube Channel. They are a great help!

I’ve created a filter menu, following your youtube channel and it works great.
However, when I add two ou more categories to a project, the filters won’t work and appear together with commas.

Any tips on how to solve this?

My controller:

 <?php

    return function ($page) {

    $filterBy   = get('filter');
    $unfiltered = $page->children()->listed();
    $projects   = $unfiltered
    ->when($filterBy, function($filterBy){
        return $this->filterBy('category', $filterBy);
    })
    ->paginate(20); 
     
    $pagination = $projects->pagination();
    $filters    = $unfiltered->pluck('category', null, true); 
        return [
            'filterBy' => $filterBy, 
            'unfiltered' => $unfiltered,
            'projects' => $projects,
            'pagination' => $pagination,
            'filters' => $filters                

        ];
    };

Thank you.
Best,
João

If you filter by a comma separated list of values, you have to provide the delimiter as third argument:

return $this->filterBy('category', $filterBy, ',');

Or what exactly do you mean?

Same for the pluck, method:

$filters    = $unfiltered->pluck('category', ',', true); 

Works perfectly!
Many Thanks
j