I was trying to have url like projects/type:books instead of projects/type/books, using routes and controllers. Everything works fine if I use type/books or type_books or type;books but it doesn’t work with ‘:’.
Is there a way to fix it?
My config.php
'routes' => [
[
'pattern' => 'projects/type:(:any)',
'action' => function ($type) {
return page('projects')->render([
'type' => $type
]);
}
]
]
My controller
return function ($page, $type) {
$projects = page('projects')->children()->listed();
if ($type) {
$projects = $projects->filterBy('category', ucfirst($type), ',');
}
return [
'projects' => $projects,
];
};