RouteEnhancer For Type Plugin With Different Number Of Parameter
i need the possibility to omit one or more parameter in my urls. For example:
domain.tld/page/my-article/
domain.tld/page/cat/2/my-article
both urls show the same page.
This works for the first variant:
myplugin:
limitToPages:
- 80
type: Plugin
routePath: '/{uid}'
namespace: tx_myext_pi1
requirements:
uid: '[0-9]{1,4}'
aspects:
uid:
type: PersistedAliasMapper
tableName: tx_myext_items
routeFieldName: slug
and this for the second:
myplugin:
limitToPages:
- 80
type: Plugin
routePath: '/cat/{cat}/{uid}'
namespace: tx_myext_pi1
requirements:
cat '[0-9]{1}'
uid: '[0-9]{1,4}'
aspects:
uid:
type: PersistedAliasMapper
tableName: tx_myext_items
routeFieldName: slug
cat:
type: StaticRangeMapper
start: '1'
end: '10'
But i cannot get them both working ... Is there a possibilty to define a route enhancer which allows to ignore the cat parameter?
Thanks!
Answer
After a few hours of trying i found the (obvious) solution. In fact there are quite many possibilities if you mind the correct order of definitions which i didn`t.
Every routePath belongs to a distinct route enhancer with distinct name. The route pathes must be distinguishly from the beginningof the line:
this works:
myplugin1:
routePath: '/{id}'
myplugin2:
'/u/{unit}/{id}'
this dont:
myplugin1:
routePath: '/{id}'
myplugin2:
'/{id}/u/{unit}'
because the first term /{id} is the same in both definitions.
(Please keep in mind that this is often a very bad idea because of duplicate content! Sometimes this does not matter ... )
Related Questions
- → October CMS - How to correctly route
- → .htaccess - not routing to public folder
- → Lumen role middleware missing argument
- → Laravel 5 Cashier Middleware Routing Error
- → Dynamic url segment name in laravel 5.1
- → Laravel show data from key column not from id
- → Laravel 4.2 application occurs unnecessary redirection after uploading live server
- → Laravel 5 route::group more than one controller issue
- → Laravel group routing issue
- → How to pass default parameters to laravel controller in a get route
- → Can't route in Laravel framework
- → Laravel 5 routing using prefix
- → Uncaught Error: Invariant Violation: Element type is invalid: Object