Filter via routes by URL

I make use of ‘Filtering via routes’. This outputs for example:

/solutions/branche:healthcare
/solutions/branche:fintech

I was wondering if it is possible to change this somehow to:

/solutions/?branche=healthcare
/solutions/?branche=fintech

I make use of the following route:

'routes' => [
    [
        'pattern' => 'solutions/branche/(:any)',
        'action' => function ($branche) {
            return page('solutions')->render([
                'branche' => $branche
            ]);
        }
    ],  

And controller:

<?php

return function ($page, $branche) {

    $articles = $page->children()->listed();

    if ($branche) {
        $articles = $articles->filterBy('branchecategory', $branche, ',');
    }

    return [
        'articles' => $articles
    ];

};

Thanks!

The whole purpose of filtering via routes is to avoid using parameters or query strings. That’s why the urls become /solutions/branche/fintech

If you don’t want that, you don’t need the route but can do the filtering by query string in your controller.

1 Like

Oke! Going to try that.
Thank you :slight_smile: