Search code examples
urlurl-rewritingtypo3tx-newstypo3-9.x

How to get Speaking URLs for News 7.0.7 on Typo3 9.5.0


I really like the ease Typo3 9.5.0 is creating speaking URL's.

The only problem I do have is to make it work with extensions like news. Could not find a way to make it work and have no clue where to start. Appreciate your help.

Best regards Dan

TYPO3 9.5.0 News 7.0.7


Solution

  • You can do this with the routeEnhancers directive in your site configuration YAML file (typically htdocs/config/sites//config.yaml). There is an example in the official documentation, though hidden a little bit:

    https://docs.typo3.org/typo3cms/extensions/core/Changelog/9.5/Feature-86365-RoutingEnhancersAndAspects.html

    This is a configuration I am actively using:

    rootPageId: <site id>
    ...
    routeEnhancers:
     NewsPlugin:
      type: Extbase
      limitToPages:
        - 49 (when your news detail page id is 49)
        - ...
      extension: News
      plugin: Pi1
      routes:
        -
         routePath: '/blog/{page}'
         _controller: 'News::list'
         _arguments:
           page: '@widget_0/currentPage'
        -
         routePath: '/tag/{tag_name}'
         _controller: 'News::list'
         _arguments:
           tag_name: overwriteDemand/tags
        -
         routePath: '/{news_title}'
         _controller: 'News::detail'
         _arguments:
           news_title: news
        -
         routePath: '/archive/{year}/{month}'
         _controller: 'News::archive'
      defaultController: 'News::list'
      defaults:
       page: '0'
      aspects:
       news_title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment