Search code examples
typo3-9.xtx-news

TYPO3 - tx_news Speaking URL route if storage out of root page lead to error "The requested page does not exist"


There are existing websites with page tree

Root Website 1

  • Folder: News Storage 1
  • Page: News List/Detail 1

Root Website 2

  • Folder: News Storage 2
  • Page: News List/Detail 2

When I try to show on "News List/Detail 2" Entity form "News Storage 1" its work for the list view. But in detail view, I have Error "The requested page does not exist" And the opposite.

If place Storage folder in the same level root page - don't work. Also, if delete routeEnhancers From Site configuration - all works. It's simple:

  News:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      -
        routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news

    defaultController: 'News::list'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment

Looks like a problem with URL route. But how fix?

I use TYPO3 9.5.22, tx_news 7.3.1.

Question. How allow show entity in detail view from other root pages and use URL routing? Thx for the advice :)

Update: Same problem for another routing like Extbase. If skip SLUG from routing configuration all works). Like, use title instead of the slug. Should be a problem in slug prefix or suffix logic.

So config like that

News:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      -
        routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news

    defaultController: 'News::list'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: uid

Works but URLs are not the best looking (. Why slug is buggy?


Solution

  • I found the answer in other case here https://stackoverflow.com/a/61673990/4796923. I pretty sure that this case will appear for other developers.

    The problem in slug configuration:

    Original configuration

    $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['path_segment']['config'] = [
        'type' => 'slug',
        'size' => 50,
        'generatorOptions' => [
            'fields' => ['title'],
            'replacements' => [
                '/' => '-'
            ],
        ],
        'fallbackCharacter' => '-',
        'eval' => 'uniqueInSite',
        'default' => ''
    ];
    

    option eval' => 'uniqueInSite' don't work if you need use Entitties over cross website, so you need replace to eval' => 'unique'

    And all works. Im my case also was needed add routeValuePrefix: '' in routing config like

    aspects:
      fund_slug:
        type: PersistedAliasMapper
        tableName: tx_lloyd_domain_model_fund
        routeFieldName: slug
        routeValuePrefix: ''
    

    But for tx_news firs fix works