【问题标题】:Typo3 8.7.x / Extbase / Realurl: Add prefix for generated html pageTypo3 8.7.x / Extbase / Realurl:为生成的html页面添加前缀
【发布时间】:2018-11-07 15:47:49
【问题描述】:

是否可以通过 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

【问题讨论】:

    标签: php typo3 extbase typo3-8.x realurl


    【解决方案1】:

    据我所知,唯一的解决方案是使用添加此行为的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;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-30
      • 2019-05-21
      • 1970-01-01
      • 1970-01-01
      • 2018-12-11
      • 1970-01-01
      相关资源
      最近更新 更多