georgringer / news

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

The "List of selected items" view with "sort by" setting does not respect language overlay #2369

Open Idleworks opened 8 months ago

Idleworks commented 8 months ago

Bug Report

Current Behavior Place a news plugin with view type "List of selected items" on a localized page. Select default language of one or more single news records. Select any "Sort by" option e.g. "Given date/time".

Expected behavior/output Localized news should appear on frontend page but result is an empty page.

Environment

Possible Solution If "sort by" option is NOT set, uids of selected news records are passed to findByIdentifier() method of repository which seems to look in uid AND l10n_parent. If "sort by" option is set, $query->in('uid', X) is used and localizations are missing.

Idleworks commented 8 months ago

My possible solution for now is to override NewRepository idList constraint and add l10n_parent:

$idList = $demand->getIdList();
if ($idList) {
    $commaSeparatedIdList = GeneralUtility::intExplode(',', $idList, true);
    $constraints['idList'] = $query->logicalOr(
        $query->in('uid', $commaSeparatedIdList),
        $query->in('l10n_parent', $commaSeparatedIdList)
    );
}
georgringer commented 6 months ago

not so sure if this is enough as it could include other news as well

Idleworks commented 6 months ago

I have taken a deeper look in TYPO3's repository function "findByUid/findByIdentifier" to understand what is happening when TYPO3 fetches an object directly by it's uid, it sets three query settings:

respectStoragePage => false Makes sense as we don't want PID restrictions when we ask for a specific uid. I know that this setting is also set if you as an editor don't select a startpoint page but I had some issues when an editor switches plugin mode and flexform setting was hidden but processed in controller.

respectSysLanguage => false Backend editors may select record's default language in plugin's flexform field, so don't care what language was selected

languageOverlayMode => true Overlay selected record to fit current website language