简体   繁体   English

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

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

Is it possible to add a prefix for the generated pages of my extension by realurl? 是否可以通过realurl为扩展程序的生成页面添加前缀? I'm using the following configuration: 我正在使用以下配置:

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

Now I've got a url like this: https://www.mydomain/galerie/2016-foobar/1.html But I want this https://www.mydomain/galerie/2016-foobar/page1.html 现在我有一个像这样的网址: https://www.mydomain/galerie/2016-foobar/1.html但我想要这个https://www.mydomain/galerie/2016-foobar/page1.html

The only solution - as I know - will be to use a userFunc which add this behavior. 我知道,唯一的解决方案是使用userFunc添加此行为。

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

Your function should then add the page prefix on encode or remove the prefix on decode. 然后,您的函数应在编码时添加页面前缀,或在解码时删除页面前缀。

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.

相关问题 Typo3 8.7.x / Extbase:在自己的扩展中扩展RealUrl - Typo3 8.7.x / Extbase: Extend RealUrl in own extension Typo3 8.7.x / Extbase:如何获取页面的 sys_category - Typo3 8.7.x / Extbase: How to get the sys_category of a page TYPO3 8.7.x / Extbase:如何获取flexform选择树视图值? - TYPO3 8.7.x / Extbase: How to get flexform select treeview values? Typo3 8.7.x / Extbase / Typoscript:使用RECORDS时如何移除锚定包裹 - Typo3 8.7.x / Extbase / Typoscript: How to remove the anchor wrap when using RECORDS Typo3 8.7.x / Extbase / Typoscript:如何设置用于将新的自定义对象添加到tt_content(mm关系)的storagePid - Typo3 8.7.x / Extbase / Typoscript: How to set the storagePid for adding new custom object to tt_content (mm relation) Typo3 8.7.x / Typoscript:获取找到的TEXT的页面uid - Typo3 8.7.x / Typoscript: Get page uid of the TEXT which was found TYPO3 8.7.x / Typoscript:扩展ajax调用,从插入特定页面的插件中获取设置 - TYPO3 8.7.x / Typoscript: Extension ajax call, get settings from plugin inserted on specific page Typo3 8.7.x / Typoscript:无法在表格页面中添加字段 - Typo3 8.7.x / Typoscript: Can't get added field in table pages Typo3 8.7.x / Typoscript:无法从根页获取数据,幻灯片在根页之前停止 - Typo3 8.7.x / Typoscript: Can't get data from rootpage, slide stops before rootpage TYPO3 7.6.x Extbase验证 - TYPO3 7.6.x Extbase Validation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM