我使用了Changelog上的逐字示例:
我唯一更改的是limitToPages。
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [82]
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: 'path_segment'
routeValuePrefix: '/'
这在9.5.4中引发异常:
Symfony\Component\Routing\Exception\InvalidParameterException
Parameter "tx_news_pi1__news" for route "tx_news_pi1_0" must match "[^/]++" ("" given) to generate a corresponding URL.
in /var/www/example/htdocs/typo3_src-9.5.4/vendor/symfony/routing/Generator/UrlGenerator.php line 155
at Symfony\Component\Routing\Generator\UrlGenerator->doGenerate(array('tx_news_pi1__news' => 0), array('_controller' => 'News::detail'), array(), array(array('variable', '/', '[^/]++', 'tx_news_pi1__news', true), array('text', '/aktuelles/artikel')), array('tx_news_pi1__news' => ''), 'tx_news_pi1_0', 1, array(), array())
in /var/www/example/htdocs/typo3_src-9.5.4/vendor/symfony/routing/Generator/UrlGenerator.php line 128
当前,不存在其他路由增强器。但是我在完全相同的页面上成功使用了更简单的配置,并且可以正常工作:
NewsDetail:
type: Extbase
limitToPages: [82]
extension: News
plugin: Pi1
routes:
- { routePath: '/{news_id}', _controller: 'News::detail', _arguments: {'news_id': 'news'} }
不确定在哪里查找以及如何进行最佳故障排除。我希望有人遇到类似的问题,或者可以指出正确的方向。
答案 0 :(得分:1)
检查此处是否存在空的path_segment:
select count(*) from tx_news_domain_model_news where path_segment='';
如果新闻条目的标题为空,则可能要删除它们或先更新标题。
答案 1 :(得分:1)
对我来说是同样的问题,问题是因为安装工具向导生成的“ path_segment”带有斜线,例如:“ the-path / another-segment”
解决方案是检查“ path_segment”中的斜线并将其替换为另一个符号,请像这样请求:
SELECT uid, pid, path_segment, title FROM tx_news_domain_model_news WHERE path_segment LIKE "%/%";
并像这样更改path_segment:“ the-path_another-segment”