Смещение содержимого не останавливается в системной папке с версии TYPO3 v10 — Как решить?

#typo3 #typoscript #typo3-10.x

Вопрос:

Запись TSRef для slide объясняет:

До версии 9 TYPO3 скольжение прекращалось при достижении папки. Начиная с TYPO3 10, это уже не так. Смотрите $cObj->checkPid_badDoktypeList .

Хорошо, эта переменная по-прежнему равна 255 (раньше напрямую, теперь через константу PageRepository::DOKTYPE_RECYCLER ).

Что именно я должен там увидеть, что мне поможет? Или лучше, как заставить смещение содержимого работать по-прежнему, как раньше?

Ответ №1:

Вы должны расширить класс ContentObjectRenderer и перезаписать метод getSlidePids своим собственным расширением.

В функции загрузки ext_localconf.php:

 $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3CMSFrontendContentObjectContentObjectRenderer::class] = [
        'className' => YourVendorYourExtensionKeyContentObjectContentObjectRenderer::class
    ];
 

Затем вам нужно создать свой собственный «Classes/ContentObject/ContentObjectRenderer.php » с:

 <?php

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

namespace YourVendorYourExtensionContentObject;

use TYPO3CMSCoreDomainRepositoryPageRepository;
use TYPO3CMSCoreUtilityGeneralUtility;

class ContentObjectRenderer extends TYPO3CMSFrontendContentObjectContentObjectRenderer
{

    /**
     * Returns all parents of the given PID (Page UID) list
     *
     * @param string $pidList A list of page Content-Element PIDs (Page UIDs) / stdWrap
     * @param array $pidConf stdWrap array for the list
     * @return string A list of PIDs
     * @internal
     */
    public function getSlidePids($pidList, $pidConf)
    {
        // todo: phpstan states that $pidConf always exists and is not nullable. At the moment, this is a false positive
        //       as null can be passed into this method via $pidConf. As soon as more strict types are used, this isset
        //       check must be replaced with a more appropriate check like empty or count.
        $pidList = isset($pidConf) ? trim($this->stdWrap($pidList, $pidConf)) : trim($pidList);
        if ($pidList === '') {
            $pidList = 'this';
        }
        $tsfe = $this->getTypoScriptFrontendController();
        $listArr = null;
        if (trim($pidList)) {
            $listArr = GeneralUtility::intExplode(',', str_replace('this', (string)$tsfe->contentPid, $pidList));
            $listArr = $this->checkPidArray($listArr);
        }
        $pidList = [];
        if (is_array($listArr) amp;amp; !empty($listArr)) {
            foreach ($listArr as $uid) {
                $page = $tsfe->sys_page->getPage($uid);

                if($page['doktype'] == PageRepository::DOKTYPE_SYSFOLDER)
                    break;

                if (!$page['is_siteroot']) {
                    $pidList[] = $page['pid'];
                }
            }
        }
        return implode(',', $pidList);
    }

}