diff --git a/CHANGELOG.md b/CHANGELOG.md index aa0fec9d..c6ae66f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This changelog is according to [Keep a Changelog](http://keepachangelog.com). All notable changes to this project will be documented in this file. We will follow [Semantic Versioning](http://semver.org/). +## UNRELEASED +### Fixed +- Show warning on linking suggestions when content element is set to "All Languages" instead of fatal exception + ## 9.0.1 July 6, 2023 ### Fixed - Content Security Policy issues in CMS12 by adding extra parameter within BackendYoastConfig and removing unnecessary inline code within FocusKeywordAnalysis.html diff --git a/Classes/Form/Element/InternalLinkingSuggestion.php b/Classes/Form/Element/InternalLinkingSuggestion.php index e1ac51ff..7ef0d3ac 100644 --- a/Classes/Form/Element/InternalLinkingSuggestion.php +++ b/Classes/Form/Element/InternalLinkingSuggestion.php @@ -48,6 +48,13 @@ public function __construct(NodeFactory $nodeFactory, array $data) public function render(): array { + $locale = $this->getLocale($this->currentPage); + if ($locale === null) { + $this->templateView->assign('languageError', true); + $resultArray['html'] = $this->templateView->render(); + return $resultArray; + } + $publicResourcesPath = PathUtility::getPublicPathToResources(); $resultArray = $this->initializeResultArray(); @@ -67,7 +74,7 @@ public function render(): array ], 'linkingSuggestions' => [ 'excludedPage' => $this->currentPage, - 'locale' => $this->getLocale($this->currentPage) + 'locale' => $locale ], 'urls' => [ 'workerUrl' => $workerUrl, @@ -95,10 +102,9 @@ protected function getLocale(int $pageId): ?string $siteFinder = GeneralUtility::makeInstance(SiteFinder::class); try { $site = $siteFinder->getSiteByPageId($pageId); - } catch (SiteNotFoundException $e) { + return $site->getLanguageById($this->languageId)->getTwoLetterIsoCode(); + } catch (SiteNotFoundException|\InvalidArgumentException $e) { return null; } - $siteLanguage = $site->getLanguageById($this->languageId); - return $siteLanguage->getTwoLetterIsoCode(); } } diff --git a/Resources/Private/Language/BackendModule.xlf b/Resources/Private/Language/BackendModule.xlf index 2adaf9b8..265e3c7e 100644 --- a/Resources/Private/Language/BackendModule.xlf +++ b/Resources/Private/Language/BackendModule.xlf @@ -193,6 +193,12 @@ To improve your site structure, consider linking to other relevant pages or records on your website. In the list below you'll find suggestions, cornerstone content is highlighted with an asterisk (*). + + Unable to determine linking suggestions. + + + This content element does not have a language to analyze. + Page diff --git a/Resources/Private/Templates/TCA/InternalLinkingSuggestion.html b/Resources/Private/Templates/TCA/InternalLinkingSuggestion.html index 46a2be1c..21885436 100644 --- a/Resources/Private/Templates/TCA/InternalLinkingSuggestion.html +++ b/Resources/Private/Templates/TCA/InternalLinkingSuggestion.html @@ -1,2 +1,28 @@ -

-
+ + + + +
+
+ +
+
+ +
+
+
+ +
+

+ +

+
+
+ + + +