使用RealURL处理可以为空的参数

问题描述 投票:1回答:1

我有一个生成的路径,包含不同的类别和使用自己的扩展名制作的产品。可以有一个,两个或三个类别,以及低于第二或第三类别的产品。

应该有效的URL示例:

/mainCategory/
/mainCategory/secondCategory/
/mainCategory/secondCategory/product-title
/mainCategory/secondCategory/thirdCategory/
/mainCategory/secondCategory/thirdCategory/product-title

现在的问题是不需要使用thirdCategory来显示产品。 我的配置:

'fixedPostVars' =>
    [
        'produkt' =>
            [
                0 =>
                     [
                          'GETvar' => 'tx_vendor_plugin[mainCategory]',
                           'lookUpTable' =>
                               [
                                   'table' => 'sys_category',
                                   'id_field' => 'uid',
                                   'alias_field' => 'title',
                                   'languageGetVar' => 'L',
                                   'languageField' => 'sys_language_uid',
                                   'transOrigPointerField' => 'l10n_parent',
                                   'useUniqueCache' => 1,
                                   'useUniqueCache_conf' =>
                                       [
                                           'strtolower' => 1,
                                           'spaceCharacter' => '-',
                                       ],
                                    ],
                            ],
                        1 =>
                            [
                                'GETvar' => 'tx_vendor_plugin[subCategory]',
                                'lookUpTable' =>
                                    [
                                        'table' => 'sys_category',
                                        'id_field' => 'uid',
                                        'alias_field' => 'title',
                                        'languageGetVar' => 'L',
                                        'languageField' => 'sys_language_uid',
                                        'transOrigPointerField' => 'l10n_parent',
                                        'useUniqueCache' => 1,
                                        'useUniqueCache_conf' =>
                                            [
                                                'strtolower' => 1,
                                                'spaceCharacter' => '-',
                                            ],
                                    ],
                            ],
                        2 =>
                            [
                                'GETvar' => 'tx_vendor_plugin[thirdCategory]',
                                'lookUpTable' =>
                                    [
                                        'table' => 'sys_category',
                                        'id_field' => 'uid',
                                        'alias_field' => 'title',
                                        'languageGetVar' => 'L',
                                        'languageField' => 'sys_language_uid',
                                        'transOrigPointerField' => 'l10n_parent',
                                        'useUniqueCache' => 1,
                                        'useUniqueCache_conf' =>
                                            [
                                                'strtolower' => 1,
                                                'spaceCharacter' => '-',
                                            ],
                                    ],
                            ],
                        3 =>
                            [
                                'GETvar' => 'tx_vndor_plugin[product]',
                                'lookUpTable' =>
                                    [
                                        'table' => 'tx_vendor_domain_model_product',
                                        'id_field' => 'uid',
                                        'alias_field' => 'title',
                                        'languageGetVar' => 'L',
                                        'languageField' => 'sys_language_uid',
                                        'transOrigPointerField' => 'l10n_parent',
                                        'useUniqueCache' => 1,
                                        'useUniqueCache_conf' =>
                                            [
                                                'strtolower' => 1,
                                                'spaceCharacter' => '-',
                                            ],
                                    ],
                            ],
                    ],

当我将noMatch => bypass添加到thirdCategory时,它不会显示任何第三类。无法访问每个第三类。

当我在没有noMatch => bypass的情况下使用它时,在没有第三类的产品的URL中有一个空路径参数:/mainCategory/secondCategory//product-title

谁可以帮助我?

typo3 typo3-8.x realurl
1个回答
2
投票

不久前在TYPO3 Slack中被问及answered by Dmitry

换句话说:你可以在postVar的开头或中间有可选参数。

因此,判决结果是RealURL无法做到这一点。

一个例子:

/mainCategory/secondCategory/product-title/
/mainCategory/secondCategory/thirdCategory/

RealURL应该如何知道在这里解码product-titlethirdCategory?它很模糊,因为它可能是产品或类别。这就是为什么RealURL使用空路径段来处理在开头/中间可选的任何内容。

© www.soinside.com 2019 - 2024. All rights reserved.