diff --git a/packages/vitec/Classes/Seo/VitecMetaHandler.php b/packages/vitec/Classes/Seo/VitecMetaHandler.php index c087a85..ea3642e 100644 --- a/packages/vitec/Classes/Seo/VitecMetaHandler.php +++ b/packages/vitec/Classes/Seo/VitecMetaHandler.php @@ -149,14 +149,16 @@ class VitecMetaHandler extends MetaHandler // title -> seo_title) counts as "not maintained". $seoTitle = trim((string)($page['seo_title'] ?? '')); $pageTitle = trim((string)($page['title'] ?? '')); - $seoTitleMaintained = $seoTitle !== '' && mb_strtolower($seoTitle) !== mb_strtolower($pageTitle); + // "Aligo | VITEC" as seo_title is the import pattern, not editor work. + $seoCore = trim((string)preg_replace('/\s*[|\x{2013}\-]\s*vitec\s*$/iu', '', $seoTitle)); + $seoTitleMaintained = $seoCore !== '' && mb_strtolower($seoCore) !== mb_strtolower($pageTitle); if ($newsUid === 0 && $productArg === '' && $usecaseUid === 0 - && $title !== '' && mb_strlen($title) < 30 + && $pageTitle !== '' && mb_strlen($pageTitle) < 30 && !$seoTitleMaintained ) { $parentTitle = $this->parentTitle($pageInfo); - if ($parentTitle !== '' && mb_stripos($title, $parentTitle) === false) { - $title .= ' | ' . $parentTitle; + if ($parentTitle !== '' && mb_stripos($pageTitle, $parentTitle) === false) { + $title = $pageTitle . ' | ' . $parentTitle; } } @@ -237,10 +239,13 @@ class VitecMetaHandler extends MetaHandler if ($pageInfo === null) { return ''; } + // Rootline keys are the depth (0 = root), but the array is krsort()ed + // (current page first). Sort by depth and take the entry before last. $rootLine = $pageInfo->getRootLine(); - $parent = $rootLine[1] ?? null; - if (!is_array($parent) || count($rootLine) < 3) { - // parent is the root page (rootline: current, root) or missing + ksort($rootLine); + $byDepth = array_values($rootLine); + $parent = count($byDepth) >= 3 ? ($byDepth[count($byDepth) - 2] ?? null) : null; + if (!is_array($parent)) { return ''; } if (in_array((int)($parent['doktype'] ?? 1), [3, 4, 199, 254, 255], true)) {