georgringer / news

TYPO3 Extension news
GNU General Public License v2.0
264 stars 355 forks source link

[7.3.1 / 9.5.11] Detailview ignores config.sys_language_overlay hideNonTranslated #1106

Closed Schweriner closed 2 years ago

Schweriner commented 4 years ago

Hey out there,

I've got a problem with the actual versions. I don't want news to be shown in other languages detail view if they have not been translated. But this, however does not work. config.sys_language_overlay hideNonTranslated should do the job - but it doesnt. It will always fallback to the default languages news detail.

Maybe this is related to: (?) https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.5/Important-82363-MakeExtBaseTranslationHandlingConsistentWithTyposcript.html

jokumer commented 4 years ago

Please check, if it is related to #815

Schweriner commented 4 years ago

Took a long look at it before but none of the mentioned "possible solutions" worked for the detail view. But yes probably its related.

web2date commented 4 years ago

Any solutions or fixes on this issue in news detail view? Still valid with TYPO3 9.5.13 and News 7.3.1

wazum commented 4 years ago

Hm, I guess the problem is the property mapper that calls \TYPO3\CMS\Extbase\Persistence\Generic\Backend::getObjectByIdentifier to retrieve the objects and this sets $query->getQuerySettings()->setRespectSysLanguage(false); $query->getQuerySettings()->setLanguageOverlayMode(true); and this is not what we want here. I'll solve this for a client project (I hope) by using the SIGNAL_NEWS_DETAIL_ACTION signal and fetching the news record there again.

wazum commented 4 years ago

Solved (for me) by using the slot

/** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
$signalSlotDispatcher->connect(
    \GeorgRinger\News\Controller\NewsController::class,
    'detailAction',
    \Vendor\Extension\Slots\NewsControllerSlot::class,
    'detailActionSlot',
    true
);

and the method

class NewsControllerSlot
{
…
    /**
     * @param News $news
     * @param int $currentPage
     * @param NewsDemand $demand
     * @param array $settings
     * @param array $extendedVariables
     * @return array
     */
    public function detailActionSlot(
        ?News $news,
        int $currentPage,
        NewsDemand $demand,
        array $settings,
        array $extendedVariables
    ): array {
        if ($news) {
            $repository = GeneralUtility::makeInstance(NewsRepository::class);
            $news = $repository->findByUid($news->getUid());
        }

        return [
            'newsItem' => $news,
            'currentPage' => $currentPage,
            'demand' => $demand,
            'settings' => $settings,
            'extendedVariables' => $extendedVariables
        ];
    }
}
georgringer commented 2 years ago

closing this issue because core issue or integrator job, using e.g. this slot