TYPO3 9.5 - 新路由增强器的问题
TYPO3 9.5 - Problems with new Routing Enhancers
我正在尝试为 extbase 扩展设置新的语音 URL 路由。但是前端的详细信息链接绝对没有任何反应。
这是我的 yaml 站点配置代码(NewsPlugin 配置有效,但 CardealerPlugin 无效):
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [92,93]
extension: News
plugin: Pi1
routes:
- { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
defaultController: 'News::detail'
aspects:
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'title'
routeValuePrefix: '/'
CardealerPlugin:
type: Extbase
limitToPages: [84,90]
extension: Cardealer
plugin: Pi1
routes:
- { routePath: '/{model_description}', _controller: 'Cardealer::show', _arguments: {'model_description': ' car'} }
defaultController: 'Cardealer::show'
aspects:
model_description:
type: PersistedAliasMapper
tableName: 'tx_cardealer_domain_model_car'
routeFieldName: 'model_description'
routeValuePrefix: '/'
extTables.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Cardealer',
'Pi1',
'Cardealer'
);
有人可以帮忙吗?
差不多一周后我找到了解决办法!
a) 我的扩展记录现在有新的 slug TCA 字段,它生成唯一的 URL 段。
'slug' => [
'exclude' => true,
'label' => 'URL Segment',
'config' => [
'type' => 'slug',
'prependSlash' => true,
'generatorOptions' => [
'fields' => ['title'],
'prefixParentPageSlug' => true,
],
'fallbackCharacter' => '-',
'eval' => 'uniqueInSite',
],
],
b) 我的 YAML 配置:
routeEnhancers:
CardealerPlugin:
type: Extbase
limitToPages: [86]
extension: Cardealer
plugin: Pi1
routes:
-
routePath: '/{uid_var}'
_controller: 'Standard::show'
_arguments:
uid_var: car
defaultController: 'Standard::list'
aspects:
uid_var:
type: PersistedAliasMapper
tableName: 'tx_cardealer_domain_model_car'
routeFieldName: 'slug'
c) 流体 link
<f:link.action action="show" controller="Standard" pageUid="{settings.pid.details}" arguments="{car: '{car.uid}'}">
目前存在一个错误 https://forge.typo3.org/issues/87542 如果在 TypoScript 设置中为您的插件启用了“skipDefaultArguments”功能,该错误会中断非默认插件控制器的路由。
因此,暂时确保 skipDefaultArguments
在您的扩展 TypoScript 配置中 未激活 :
plugin.tx_myextension {
features {
skipDefaultArguments = 0
}
}
此外,请检查扩展的默认 TypoScript 设置是否包含在您的 TypoScript 模板中。
我正在尝试为 extbase 扩展设置新的语音 URL 路由。但是前端的详细信息链接绝对没有任何反应。
这是我的 yaml 站点配置代码(NewsPlugin 配置有效,但 CardealerPlugin 无效):
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [92,93]
extension: News
plugin: Pi1
routes:
- { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
defaultController: 'News::detail'
aspects:
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'title'
routeValuePrefix: '/'
CardealerPlugin:
type: Extbase
limitToPages: [84,90]
extension: Cardealer
plugin: Pi1
routes:
- { routePath: '/{model_description}', _controller: 'Cardealer::show', _arguments: {'model_description': ' car'} }
defaultController: 'Cardealer::show'
aspects:
model_description:
type: PersistedAliasMapper
tableName: 'tx_cardealer_domain_model_car'
routeFieldName: 'model_description'
routeValuePrefix: '/'
extTables.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Cardealer',
'Pi1',
'Cardealer'
);
有人可以帮忙吗?
差不多一周后我找到了解决办法!
a) 我的扩展记录现在有新的 slug TCA 字段,它生成唯一的 URL 段。
'slug' => [
'exclude' => true,
'label' => 'URL Segment',
'config' => [
'type' => 'slug',
'prependSlash' => true,
'generatorOptions' => [
'fields' => ['title'],
'prefixParentPageSlug' => true,
],
'fallbackCharacter' => '-',
'eval' => 'uniqueInSite',
],
],
b) 我的 YAML 配置:
routeEnhancers:
CardealerPlugin:
type: Extbase
limitToPages: [86]
extension: Cardealer
plugin: Pi1
routes:
-
routePath: '/{uid_var}'
_controller: 'Standard::show'
_arguments:
uid_var: car
defaultController: 'Standard::list'
aspects:
uid_var:
type: PersistedAliasMapper
tableName: 'tx_cardealer_domain_model_car'
routeFieldName: 'slug'
c) 流体 link
<f:link.action action="show" controller="Standard" pageUid="{settings.pid.details}" arguments="{car: '{car.uid}'}">
目前存在一个错误 https://forge.typo3.org/issues/87542 如果在 TypoScript 设置中为您的插件启用了“skipDefaultArguments”功能,该错误会中断非默认插件控制器的路由。
因此,暂时确保 skipDefaultArguments
在您的扩展 TypoScript 配置中 未激活 :
plugin.tx_myextension {
features {
skipDefaultArguments = 0
}
}
此外,请检查扩展的默认 TypoScript 设置是否包含在您的 TypoScript 模板中。