简体   繁体   English

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

[英]Handling of parameters which can be empty with RealURL

I have a generated path with different categories and products made with an own extension. 我有一条生成的路径,其中包含不同的类别和使用自己的扩展程序制造的产品。 There can be one, two or three categories, plus a product below the second or third category. 可以有一个,两个或三个类别,再加上第二个或第三个类别下方的产品。

Examples of URLs that should work: 可以使用的网址示例:

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

The problem now is the not required thirdCategory to show the product. 现在的问题是显示产品不是必需的thirdCategory。
My configuration: 我的配置:

'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' => '-',
                                            ],
                                    ],
                            ],
                    ],

When I add noMatch => bypass to the thirdCategory, it doesn't show up any third category. 当我向noMatch => bypass添加noMatch => bypass ,它不会显示任何第三类别。 Every third category cannot be accessed. 每三个类别都无法访问。

When I use it without noMatch => bypass , there is an empty path parameter in the URL for products without third category: /mainCategory/secondCategory//product-title 当我不带noMatch => bypass使用它时,URL中有一个空路径参数,用于不包含第三类的产品: /mainCategory/secondCategory//product-title

Who can help me with that? 谁可以帮助我呢?

This was asked and answered by Dmitry in the TYPO3 Slack a while ago: 这是德米特里(Dmitry)在TYPO3 Slack中提出并回答的

In other words: you can;t have optional parameters in the beginning or middle of the postVar. 换句话说:在postVar的开头或中间不能有可选参数。

Thus the verdict is that this is impossible with RealURL. 因此,可以断定RealURL不可能做到这一点。

An example: 一个例子:

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

How should RealURL know what to decode product-title and thirdCategory here? RealURL应该如何知道在此处解码product-titlethirdCategory It's ambiguous since it could be a product or a category. 这是模棱两可的,因为它可能是产品或类别。 That's why RealURL uses empty path segments for anything which can be optional in the beginning/middle. 这就是为什么RealURL对任何在开头/中间可以选择的内容都使用空路径段的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM