0

We have a Typo3 9 server with a number of websites running on it. We also have the news plugin to facilitate the addition of blog posts.

With Typo3 9 the old RealURL system has been depricated in favour of a built in system. This is working for the normal pages but is not working for the news articles.

We have implemented the following YAML confic file which is based off the examples provided by the news plugin and a number of other stack overflow posts. The problem is that while we can confirm that the config is loaded, we get a 404 error:

404 Page not found!

Reason: The requested page does not exist

Current URL: /blog/2020-january/

We then commenced in depth, line by line examinantion of the code to understand what is going wrong. We did manage to render the /blog/2020-january/ page, but it had no content. None of the individual blog pages resolve either.

Are there other configurations that we should look for to enable this functionality? We have had another Typo3 person look at the problem without success.

rootPageId: 156
base: 'https://example.site'
baseVariants: {  }
languages:
  -
    title: English
    enabled: true
    languageId: '0'
    base: /
    typo3Language: default
    locale: en_AU
    iso-639-1: en
    navigationTitle: ''
    hreflang: ''
    direction: ''
    flag: au
errorHandling: {  }
routes: {  }
routeEnhancers:
    PageTypeSuffix:
      type: PageType
      default: '/'
      index: '/'
      map:
        '/': 0
    NewsPlugin:
        type: Extbase
        extension: News
        plugin: Pi1
        limitToPages:
          - 187
          - 201
        routes:
          # Detail view:
          - routePath: '/{news_title}'
            _controller: 'News::detail'
            _arguments: {'news_title': 'news'}
          # Categories:
          - routePath: '/{category}'
            _controller: 'News::list'
            _arguments: {'category': 'overwriteDemand/categories'}
          # Tags:
          - routePath: '/{tag_name}'
            _controller: 'News::list'
            _arguments: {'tag_name': 'overwriteDemand/tags'}
          # Pagination:
          - routePath: '/{page}'
            _controller: 'News::list'
            _arguments: {'page': '@widget_0/currentPage'}
          # Archive:
          - routePath: '/{localized_archive}/{year}/{month}'
            _controller: 'News::archive'
          # Date:
          - routePath: '/{year}-{month}'
            _controller: 'News::list'
            _arguments:
              year: overwriteDemand/year
              month: overwriteDemand/month
        defaultController: 'News::list'
        defaults:
            page: '0'
            year: ''
            month: ''
        requirements:
            page: '\d+'
            news_title: '^[a-zA-Z0-9].*$'
        aspects:
            page:
                type: StaticRangeMapper
                start: '1'
                end: '100'
            news_title:
                type: PersistedPatternMapper
                tableName: tx_news_domain_model_news
                routeFieldPattern: '^(?P<path_segment>.+)$'
                routeFieldResult: '{path_segment}'
            category:
                type: PersistedAliasMapper
                tableName: 'sys_category'
                routeFieldName: 'title'
            tag_name:
                type: PersistedAliasMapper
                tableName: 'tx_news_domain_model_tag'
                routeFieldName: 'title'
            localized_archive:
                type: LocaleModifier
                default: 'archive'
                routeFieldName: 'title'
                localeMap:
                  - languageId: 'de_.*'
                    value: 'archiv'
                  - languageId: 'fr_.*'
                    value: 'archives'
            year:
                type: StaticRangeMapper
                start: '1970'
                end: '2099'
            month:
                type: StaticValueMapper
                map:
                  january: '01'
                  february: '02'
                  march: '03'
                  april: '04'
                  may: '05'
                  june: '06'
                  july: '07'
                  august: '08'
                  september: '09'
                  october: 10
                  november: 11
                  december: 12
tl8
  • 537
  • 5
  • 22
  • Does the list of news render when you open /blog/? Are URLs correctly generated fo the links? – j4k3 May 27 '20 at 08:22
  • No, opening /blog/ doesn't show a list of articles. The only thing on the page is the date selector drop down. When selected, this does go to the correct url (eg /blog/2020-january/) – tl8 May 27 '20 at 23:14
  • You may be facing the same error I've just ran into a few days ago. The resolver now checks for the eval setting uniqueInSite. Unfortually the implementation is not thought through. Are your news-records somewhere in the path of your site or are they outsite, uesd globally? The bug was introduces 2 months ago, I guess 9.5.16 and 9.5.17 are affected. – j4k3 May 28 '20 at 09:52
  • Heres a link to the problem I had and the answer: https://stackoverflow.com/a/62009785/329613 – j4k3 May 28 '20 at 10:02
  • I looked through our code base, and the change is not there. So it is unlikely to be that bug. – tl8 Jun 09 '20 at 04:52
  • You may be right, I only took a glance a month ago. The code is in fact completely different in the 10 branch. You might luck out just upgrading your installation. Fingers crossed. – j4k3 Jun 09 '20 at 05:25

2 Answers2

0
Please check your code see below code of news_title

routeEnhancers: News: type: Extbase extension: News plugin: Pi1 routes: - routePath: '/{news-title}' _controller: 'News::detail' _arguments: news-title: news aspects: news-title: type: PersistedAliasMapper tableName: tx_news_domain_model_news routeFieldName: path_segment

Remove curly braces from path_segment, remove do it as above or in docs thank you

Please see the official documents https://docs.typo3.org/p/georgringer/news/7.2/en-us/AdministratorManual/BestPractice/Routing/Index.html

0

After a lot of effort we have success.

Firstly, the final working config:

routeEnhancers:
  NewsPlugin:
    type: Extbase
    extension: News
    plugin: Pi1
    limitToPages:
      - 201
      - 187
    routes:
      -
        routePath: '/{news_title}'
        _controller: 'News::detail'
        _arguments:
          news_title: news
      -
        routePath: '/{category}'
        _controller: 'News::list'
        _arguments:
          category: overwriteDemand/categories
      -
        routePath: '/{tag_name}'
        _controller: 'News::list'
        _arguments:
          tag_name: overwriteDemand/tags
      -
        routePath: '/page-{page}'
        _controller: 'News::list'
        _arguments:
          page: '@widget_0/currentPage'
      -
        routePath: '/{year}/{month}'
        _controller: 'News::list'
        _arguments:
          year: overwriteDemand/year
          month: overwriteDemand/month
    defaultController: 'News::list'
#    defaults:
#      page: '0'
#      year: ''
#      month: ''
    requirements:
      page: \d+
#      news_title: '^[a-zA-Z0-9].*$'
    aspects:
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      news_title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      category:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: title
      tag_name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: title
      year:
        type: StaticRangeMapper
        start: '1970'
        end: '2099'
      month:
        type: StaticRangeMapper
        start: '01'
        end: '12'
      #month:
      #  type: StaticValueMapper
      #  map:
      #    january: '01'
      #    february: '02'
      #    march: '03'
      #    april: '04'
      #    may: '05'
      #    june: '06'
      #    july: '07'
      #    august: '08'
      #    september: '09'
      #    october: 10
      #    november: 11
      #    december: 12

The important things:

  • The pagination path includes the page prefix. There is no ambiguity about what page it is on.
  • No trailing slashes, additionally, the articles also can't have trailing slashes in the path segment. This can be done in the database and clearing the cache after
  • No defaults
  • The different month mapping is due to a requirement to match an existing system

We upgraded from 9.5.15 to 9.5.18. It is not clear if this was required.

In the site package, the default TypoScript template included link.skipControllerAndAction = 1. This needs to be removed to show the friendly urls for the articles in the list view. (See How to properly set url-routing for tx-news in TYPO3 9.5.5?)

Finally, for the date, tag and category filters to work, Disable override demand in List->Plugin->Additional must be unticked. overwrite demand

tl8
  • 537
  • 5
  • 22