自定义 TYPO3 扩展的 RouteEnhancer:详细信息页面上的 404
RouteEnhancer for custom TYPO3 extension: 404 on detail page
我有一个自定义的 extbase 扩展,它从 ReST 服务查询只读数据以在列表和详细信息视图中显示它。 TYPO3 table 中没有数据。
URLs 由 realURL 处理,在 TYPO3 8.
之前工作正常
现在我正在更新到 TYPO3 9.5.21,我无法让此扩展程序的 routeEnhancer 配置正常工作。我设法在 TYPO3 9 上获得完全相同的 URL 详细视图,但详细视图 returns 出现 404 错误:“TYPO3\CMS\Core\Error\Http\PageNotFoundException:请求的页面不存在”
这是config.yaml:
...
routeEnhancers:
...
News:
...
CDP_Gemeinden:
type: Extbase
# Pages containing list/detail-plugin
limitToPages:
- 43336
- 11082
# From registerPlugin @ ext_tables.php
# Extension key is dvt_cdp
extension: DvtCdp
# From configurePlugin @ ext_localconf.php
plugin: CdpGemeinden
routes:
- { routePath: '/gemeinde/{gemoestat}/', _controller: 'Gemeinden::show', _arguments: {'gemoestat': 'gemoestat'} }
defaultController: 'Gemeinden::search'
requirements:
gemoestat: '\d+'
aspects:
gemoestat:
type: StaticRangeMapper
start: '70100'
end: '70999'
第 43336 页和第 11082 页是处理列表视图和详细视图的插件。 “gemoestat”是城市的唯一 ID。在列表视图模板中创建详细视图的链接:
<f:link.action arguments="{gemoestat:gemeinde.gemoestat}" action="show">
此 URL 适用于 TYPO3 9(和 TYPO 8),无需 routeEnhancer:
.../?tx_dvtcdp_cdpgemeinden%5Baction%5D=show&tx_dvtcdp_cdpgemeinden%5Bcontroller%5D=Gemeinden&tx_dvtcdp_cdpgemeinden%5Bgemoestat%5D=70701&cHash=8cabee37a20f804e94e2af1e9f2ce02d
这是在 TYPO3 8 上运行的 URL,现在如果我激活我的 routeEnhancer 也会生成 404 错误:
.../gemeinden/gemeinde/70701/
知道缺少什么吗?详细视图在没有 routeEnhancer 的情况下工作正常,所以我不认为扩展是问题,而是 routeEnhancer 配置。
也许您的数据系统文件夹不在根页面页面树中。看这里:https://forge.typo3.org/issues/91235
再次检查routeenhancer 设置中扩展和插件的值。特别是符号、大写、小写和与 registerPlugin 参数的比较。经验表明这是犯错误最多的地方:) .. 我的错误
对于外部数据,我们需要一个自己的方面来 return 值。试试这个
config.yaml
routeEnhancers:
CDPGemeinden:
type: Extbase
extension: DvtCdp
plugin: CdpGemeinden
routes:
- routePath: 'gemeinde/{gemoestat}/'
_controller: 'Gemeinden::show'
_arguments:
gemoestat: 'gemoestat'
aspects:
gemoestat:
type: GemoestatMapper
EXT:dvt_cdp/Classes/Routing/Aspect/GemoestatMapper.php
<?php
namespace Dvt\Cdp\Routing\Aspect;
use TYPO3\CMS\Core\Routing\Aspect\StaticMappableAspectInterface;
/**
* Aspect that maps external gemoestat unique ID
*/
class GemoestatMapper implements StaticMappableAspectInterface
{
/**
* @inheritDoc
*/
public function generate(string $value): ?string
{
return $value;
}
/**
* @inheritDoc
*/
public function resolve(string $value): ?string
{
return isset($value) ? (string)$value : null;
}
}
EXT:dvt_cdp/ext_localconf.php
// Add routing aspect
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['GemoestatMapper'] =
\Dvt\Cdp\Routing\Aspect\GemoestatMapper::class;
我有一个自定义的 extbase 扩展,它从 ReST 服务查询只读数据以在列表和详细信息视图中显示它。 TYPO3 table 中没有数据。 URLs 由 realURL 处理,在 TYPO3 8.
之前工作正常现在我正在更新到 TYPO3 9.5.21,我无法让此扩展程序的 routeEnhancer 配置正常工作。我设法在 TYPO3 9 上获得完全相同的 URL 详细视图,但详细视图 returns 出现 404 错误:“TYPO3\CMS\Core\Error\Http\PageNotFoundException:请求的页面不存在”
这是config.yaml:
...
routeEnhancers:
...
News:
...
CDP_Gemeinden:
type: Extbase
# Pages containing list/detail-plugin
limitToPages:
- 43336
- 11082
# From registerPlugin @ ext_tables.php
# Extension key is dvt_cdp
extension: DvtCdp
# From configurePlugin @ ext_localconf.php
plugin: CdpGemeinden
routes:
- { routePath: '/gemeinde/{gemoestat}/', _controller: 'Gemeinden::show', _arguments: {'gemoestat': 'gemoestat'} }
defaultController: 'Gemeinden::search'
requirements:
gemoestat: '\d+'
aspects:
gemoestat:
type: StaticRangeMapper
start: '70100'
end: '70999'
第 43336 页和第 11082 页是处理列表视图和详细视图的插件。 “gemoestat”是城市的唯一 ID。在列表视图模板中创建详细视图的链接:
<f:link.action arguments="{gemoestat:gemeinde.gemoestat}" action="show">
此 URL 适用于 TYPO3 9(和 TYPO 8),无需 routeEnhancer:
.../?tx_dvtcdp_cdpgemeinden%5Baction%5D=show&tx_dvtcdp_cdpgemeinden%5Bcontroller%5D=Gemeinden&tx_dvtcdp_cdpgemeinden%5Bgemoestat%5D=70701&cHash=8cabee37a20f804e94e2af1e9f2ce02d
这是在 TYPO3 8 上运行的 URL,现在如果我激活我的 routeEnhancer 也会生成 404 错误:
.../gemeinden/gemeinde/70701/
知道缺少什么吗?详细视图在没有 routeEnhancer 的情况下工作正常,所以我不认为扩展是问题,而是 routeEnhancer 配置。
也许您的数据系统文件夹不在根页面页面树中。看这里:https://forge.typo3.org/issues/91235
再次检查routeenhancer 设置中扩展和插件的值。特别是符号、大写、小写和与 registerPlugin 参数的比较。经验表明这是犯错误最多的地方:) .. 我的错误
对于外部数据,我们需要一个自己的方面来 return 值。试试这个
config.yaml
routeEnhancers:
CDPGemeinden:
type: Extbase
extension: DvtCdp
plugin: CdpGemeinden
routes:
- routePath: 'gemeinde/{gemoestat}/'
_controller: 'Gemeinden::show'
_arguments:
gemoestat: 'gemoestat'
aspects:
gemoestat:
type: GemoestatMapper
EXT:dvt_cdp/Classes/Routing/Aspect/GemoestatMapper.php
<?php
namespace Dvt\Cdp\Routing\Aspect;
use TYPO3\CMS\Core\Routing\Aspect\StaticMappableAspectInterface;
/**
* Aspect that maps external gemoestat unique ID
*/
class GemoestatMapper implements StaticMappableAspectInterface
{
/**
* @inheritDoc
*/
public function generate(string $value): ?string
{
return $value;
}
/**
* @inheritDoc
*/
public function resolve(string $value): ?string
{
return isset($value) ? (string)$value : null;
}
}
EXT:dvt_cdp/ext_localconf.php
// Add routing aspect
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['GemoestatMapper'] =
\Dvt\Cdp\Routing\Aspect\GemoestatMapper::class;