1

In routing.yml I have defined a new route for categories:

categories:
    path: '/{slug}/'
    defaults:
        _controller: 'Bolt\Controllers\Frontend::taxonomy'
        taxonomytype: categories

But Bolt still generates url for categories following the general pattern:

taxonomylink:
    path: '/{taxonomytype}/{slug}'
    defaults:
        _controller: 'Bolt\Controllers\Frontend::taxonomy'
    requirements:
        taxonomytype: 'Bolt\Controllers\Routing::getAnyTaxonomyTypeRequirement'

E.g.: for category van-gogh the generated url is /categories/van-gogh, but I would like to generate urls like /van-gogh. I would like to leave unchanged other taxonomy types: /tags/hermitage should not become /hermitage, but it should stay the same.

How can I have Bolt do this? Thank you :)

nightlybus
  • 11
  • 3

2 Answers2

0

Set up an early route similar to this:

taxonomybinding:
    path: '/{taxonomytype}'
    defaults:
        _controller: 'Bolt\Controllers\Frontend::taxonomy'
    requirements:
        taxonomytype: 'Bolt\Controllers\Routing::getAnyTaxonomyTypeRequirement'
Gawain
  • 1,568
  • 10
  • 8
0

Set the taxonomytype to category instead of categories.

PS You should define some requirements, otherwise /hermitage would match, too, resulting in an error, because there is no category with that slug.