Ad

RouteEnhancer For Type Plugin With Different Number Of Parameter

- 1 answer

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!

Ad

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 ... )

Ad
source: stackoverflow.com
Ad