0
votes

How do I get this code from RealURL into the TYPO3 9.5 'Advanced Routing Configuration'?

With 'aspects' type 'PersistedAliasMapper', you can only map to the UID. But I want to map to another field! In my case over the 'event_id' field.

array(
                    'GETvar' => 'tx_extension_search[eventid]',
                    'lookUpTable' => array(
                        'table' => 'tx_extension_domain_model_event',
                        'id_field' => 'event_id',
                        'alias_field' => 'title_alias',
                        'useUniqueCache' => 0,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-'
                        )
                    ),
                ),
1

1 Answers

1
votes

I would suggest to add a slug field. With this the editor can handle the url segment of every record. Here are the needed changes:

SQL:

CREATE TABLE tx_extension_domain_model_event (
  slug varchar(1024) DEFAULT '' NOT NULL
);

TCA of tx_extension_domain_model_event

        'slug' => [
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:pages.slug',
            'config' => [
                'type' => 'slug',
                'size' => 50,
                'generatorOptions' => [
                    'fields' => ['title'],
                    'replacements' => [
                        '/' => '-'
                    ],
                ],
                'fallbackCharacter' => '-',
                'default' => ''
            ]
        ],

The configuration in your config.yaml, with e.g. showAction to show the details of an event:

routeEnhancers:
  YourPlugin:
    type: Extbase
    extension: ExtensionKey
    plugin: Search
    limitToPages: [Put your detailPagePid here]
    routes:
      - { routePath: '/event/{event}', _controller: 'Event::show', _arguments: {'event': 'event'}}
    defaultController: 'Event::show'
    aspects:
      event:
        type: PersistedAliasMapper
        tableName: 'tx_extension_domain_model_event'
        routeFieldName: 'slug'