Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddNewsToMenuProcessor Does not return the correct language Aspect. #2606

Open
powermix opened this issue Jan 23, 2025 · 0 comments
Open

AddNewsToMenuProcessor Does not return the correct language Aspect. #2606

powermix opened this issue Jan 23, 2025 · 0 comments

Comments

@powermix
Copy link

powermix commented Jan 23, 2025

This diff shows updates made to the AddNewsToMenuProcessor.php file to fix the translated data sets.

--- AddNewsToMenuProcessor.php	2025-01-23 12:14:56
+++ AddNewsToMenuProcessor-copy.php	2025-01-23 12:14:19
@@ -81,6 +81,8 @@
         $newsId = (int)($routing->getArguments()['tx_news_pi1']['news'] ?? 0);
 
         if ($newsId) {
+            // Get the current language ID
+            $languageId = $this->getCurrentLanguage();
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
                 ->getQueryBuilderForTable('tx_news_domain_model_news');
             $row = $queryBuilder
@@ -92,7 +94,20 @@
                 ->executeQuery()->fetchAssociative();
 
             if ($row) {
-                $row = $this->getTsfe()->sys_page->getLanguageOverlay('tx_news_domain_model_news', $row, $this->getCurrentLanguageAspect());
+                if ($languageId > 0) {
+                    $translatedRow = $queryBuilder
+                        ->select('*')
+                        ->from('tx_news_domain_model_news')
+                        ->where(
+                            $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($newsId, Connection::PARAM_INT)),
+                            $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($languageId, Connection::PARAM_INT))
+                        )
+                        ->executeQuery()->fetchAssociative();
+    
+                    if ($translatedRow) {
+                        $row = $translatedRow;
+                    }
+                }
             }
 
             if (is_array($row) && !empty($row)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant