6

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

danriesen
  • 63
  • 1
  • 5

3 Answers3

8

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
StatiX
  • 854
  • 6
  • 21
  • HI Pavel, nice, it works like a charme! Also apreciate the link to the manual. Was too hidden for me. Best regards Dan – danriesen Oct 25 '18 at 12:04
  • I am using this configuration, but there is always a chash added to my list page when going to the next page - does anyone happen to know why? – Chi Jan 30 '19 at 08:05
  • Do you think there is a way to not hardcode page IDs here for limitToPages but to say something like "limit to pages which have an news detail plugin on it"? – Martin Wunderlich Feb 22 '19 at 15:05
  • config/sites/config.yaml is this the new convention where to put the route enhancer configs? that directory does not exist by default or in previous versions with real url – netzding Jul 26 '19 at 08:55
4

Working example typo3 9.5.5 with tx_news 7.1.0 with PersistedPatternMapper:

routeEnhancers:
  NewsPlugin:
    type: Extbase
    limitToPages: [20,23,29,30]
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '{page}',_controller: 'News::list',_arguments: {'page': '@widget_0/currentPage'} }
      - { routePath: '{news_title}',_controller: 'News::detail',_arguments: {'news_title': 'news'} }      
    defaultController: 'News::list'    
    defaults:
      page: '0'
    requirements:
      page: '\d+'
    aspects:      
      news_title:
        type: PersistedPatternMapper
        tableName: 'tx_news_domain_model_news'
        routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
        routeFieldResult: '{path_segment}-{uid}'
      page:
        type: StaticRangeMapper
        start: '1'
        end: '200'
ParkerHalo
  • 4,341
  • 9
  • 29
  • 51
Han Richer
  • 41
  • 4
  • 1
    Could you please explain what these settings do in detail - or at least add a link to some documentation. – ESP32 Jul 28 '20 at 02:53
-1

the extension news is ready for using the Core URLs since version 7.0.6. Please make sure that you have the right configuration like setting up a Site in Sites module.

Thomas Löffler
  • 5,922
  • 1
  • 14
  • 29
  • ciao thomas, you sure are competent, saw many good suggestions from you, do you care to say some more on this answer, I didn't get it ... – webman Mar 10 '20 at 11:42