Search code examples
typo3url-routingaspecttypo3-10.x

TYPO3 Aspect PersistedAliasMapper not working as wanted


I am running TYPO3 10.4.6 and I have a problem with a plugin I have written. I am using a frontend plugin to show details to one of my database entities. I used a TCA field of type 'slug' to store a custom slug in database and then defined the following in my config.yaml for my site:

routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: '/'
    index: ''
    map:
      '/': 0
  Hersteller:
    type: Extbase
    limitToPages: [45]
    extension: Myext
    plugin: Hersteller
    routes:
      - { routePath: '/{hersteller}', _controller: 'Hersteller::show', _arguments: {'hersteller': 'hersteller'} }
    defaultController: 'Hersteller::show'
    aspects:
      hersteller:
        type: PersistedAliasMapper
        tableName: 'tx_myext_domain_model_hersteller'
        routeFieldName: 'slug'
        routeValuePrefix: '/'

My URLs are generated as I want them: https://example.com/pluginpage/slug

The problem is that when I access this link, TYPO3 respons with a 404 Not Found error: Page Not Found The page did not exist or was inaccessible. Reason: The requested page does not exist

Am I missing something? It seems like TYPO3 cannot map the slug to a database entity. This is the definition of the TCA slug field:

'slug' => [
    'label' => 'Slug',
    'config' => [
        'type' => 'slug',
        'generatorOptions' => [
            'fields' => ['name'],
            'fallbackCharacter' => '-',
            'eval' => 'unique'
        ]
    ]
],

What am I doing wrong? Is there maybe a way to debug this? I have no idea where to look at to dive deeper.

Thanks in advance!


Solution

  • As already mentioned by Thomas, you should remove routeValuePrefix: '/' which should solve the issue.