[英]TYPO3 9.5 Routing for custom extension (Product Navigator) - replacement of Realurl
Before TYPO3 9.5 Realurl could handle URLs and I had the following realurl configuration:在 TYPO3 9.5 Realurl 可以处理 URL 之前,我有以下 realurl 配置:
'productConfiguration' => array( array( 'GETvar' => 'tx_bitproducts_productview[product]', 'lookUpTable' => array( 'table' => 'tx_bitproducts_domain_model_product', 'id_field' => 'uid', 'alias_field' => 'productname', 'addWhereClause' => ' AND (sys_language_uid=0) AND deleted=0 AND hidden=0 AND pid=185 ', 'useUniqueCache' => 1, 'useUniqueCache_conf' => array( 'strtolower' => 1, 'spaceCharacter' => '-' ), 'enable404forInvalidAlias' => true ) ), array( 'GETvar' => 'tx_bitproducts_productview[action]', 'noMatch' => 'bypass', ), array( 'GETvar' => 'tx_bitproducts_productview[controller]', 'noMatch' => 'bypass' ), ), '195' => 'productConfiguration',
In TYPO3 9.5 I need to replace this handling.在 TYPO3 9.5 中,我需要替换这种处理方式。 My Questions are:
我的问题是:
I would be happy for any hints how to start this correctly我很乐意为您提供如何正确启动的任何提示
Short answer: No, you either have to add a slug field or add a custom aspect class简短回答:不,您必须添加一个 slug 字段或添加自定义方面类
Long answer:长答案:
So you have two possibilities: a) Add a slug field to your table and populate it with an "optimized" english value when changing the title and use the PersistedAliasMapper aspect b) Add a custom aspect class which maps the "/Some Value" segment to your optimized variant in english "/some-value" AND BACK!.因此,您有两种可能性:a) 向表中添加一个 slug 字段,并在更改标题时使用“优化的”英文值填充它,并使用 PersistedAliasMapper 方面 b) 添加映射“/Some Value”段的自定义方面类以英语“/some-value”并返回到您的优化变体!。 (In 9.5 you don't know the target language of the link [eg for language switcher], so values have to be always english, which matches your requirement :-))
(在 9.5 中,您不知道链接的目标语言 [例如语言切换器],因此值必须始终为英语,这符合您的要求 :-))
Adding an aspect class is as easy as adding one line in your ext_localconf.php:添加方面类就像在 ext_localconf.php 中添加一行一样简单:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['ASPECTNAME'] = MyAspect::class;
and writing a small Class implementing the StaticMappableAspectInterface with a generate and a resolve method.并编写一个使用 generate 和 resolve 方法实现 StaticMappableAspectInterface 的小类。
So if you know how to convert the "optimized" version back to the original using an aspect might be easier.因此,如果您知道如何使用方面将“优化”版本转换回原始版本可能会更容易。 If you can't revert the optimization the slug-field in the db might be easier.
如果您无法恢复优化,则 db 中的 slug-field 可能会更容易。 But there is no "optimize and store original value" automatism like in realurl
但是没有像 realurl 那样“优化和存储原始值”的自动化
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.