TYPO3-tx_news如果存储超出根页面会导致出现错误“所请求的页面不存在”的口语URL路由

问题描述

现有的网站带有页面树

根网站1

  • 文件夹:新闻存储1
  • 页面:新闻列表/详细信息1

根网站2

  • 文件夹:新闻存储2
  • 页面:新闻列表/详细信息2

当我尝试在“新闻列表/详细信息2”上显示实体表单“新闻存储1”时,它在列表视图中的工作。但从详细信息来看,我有错误“ The requested page does not exist”,反之亦然。

如果将“存储”文件夹放置在同一级别的根页面中-不起作用。 另外,如果从“站点”配置中删除routeEnhancers,则一切正常。很简单:

  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

似乎是URL路由问题。但是如何解决?

我使用TYPO3 9.5.22,tx_news 7.3.1。

问题。如何允许从其他根页面的详细视图中显示实体并使用URL路由?谢谢你的建议:)

更新:另一个路由(例如Extbase)也存在同样的问题。如果从路由配置中跳过SLUG,则一切正常。喜欢,使用标题而不是子弹。在子弹前缀或后缀逻辑中应该是一个问题。

如此配置

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

有效,但URL并不是最漂亮的外观。(为什么虫是越野车?

解决方法

在其他情况下,我在https://stackoverflow.com/a/61673990/4796923找到了答案。我很确定这种情况也会在其他开发人员中出现。

子弹配置中的问题:

原始配置

$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['path_segment']['config'] = [
    'type' => 'slug','size' => 50,'generatorOptions' => [
        'fields' => ['title'],'replacements' => [
            '/' => '-'
        ],],'fallbackCharacter' => '-','eval' => 'uniqueInSite','default' => ''
];
如果您需要在跨网站上使用实体,则

选项eval' => 'uniqueInSite'不起作用,因此您需要替换为eval' => 'unique'

所有作品。我的情况也需要在路由配置中添加routeValuePrefix: '',例如

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

但对于tx_news的首个修复方法有效

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...