繁体   English   中英

Typo3 8.7.x / Extbase / Realurl:为生成的html页面添加前缀

[英]Typo3 8.7.x / Extbase / Realurl: Add prefix for generated html page

是否可以通过realurl为扩展程序的生成页面添加前缀? 我正在使用以下配置:

...
'postVarSets' => [
    '_DEFAULT' => [


        'gallery' => [
            [
                'GETvar' => 'tx_myext_p1gallery[action]',
                'noMatch' => 'bypass',
            ],
            [
                'GETvar' => 'tx_myext_p1gallery[controller]',
                'noMatch' => 'bypass',
            ],
            [
                'GETvar' => 'tx_myext_p1gallery[backId]',
                'noMatch' => 'bypass',
            ],
            [
                'GETvar' => 'tx_myext_p1gallery[gallery]',
                'lookUpTable' => [
                    'table' => 'tx_myext_domain_model_gallery',
                    'id_field' => 'uid',
                    'alias_field' => 'title',
                    'addWhereClause' => 'AND NOT deleted',
                    'useUniqueCache' => 1,
                    'useUniqueCache_conf' => [
                        'strtolower' => 1,
                        'spaceCharacter' => '-',
                    ],
                ],
            ],
            [
                'GETvar' => 'tx_myext_p1gallery[page]',
            ],
        ],

现在我有一个像这样的网址: https://www.mydomain/galerie/2016-foobar/1.html但我想要这个https://www.mydomain/galerie/2016-foobar/page1.html

我知道,唯一的解决方案是使用userFunc添加此行为。

        [
            'GETvar' => 'tx_myext_p1gallery[page]',
            'userFunc' => SomeClass::class . '->somefunction'
        ],

然后,您的函数应在编码时添加页面前缀,或在解码时删除页面前缀。

public function somefunction($parameters = [])
{
  $value = $parameters['value'];

  if ($parameters['decodeAlias']) {
     return preg_replace('#^page([0-9]*)$#i', '$1', $value);
  } else {
     return 'page' . $value;
  }
}

暂无
暂无

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

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