News: Canonical auf Success Story (Feld vitec_canonical_usecase), 13 Paare gesetzt

13 Pressemeldungen tragen denselben Text wie eine Success Story
(Seobility: doppelter Inhalt). Neues Feld am News-Datensatz (Tab
'VITEC SEO', Auswahl der Story); VitecMetaHandler ersetzt damit den
Canonical-Link durch /success-stories/<slug>. Die Meldung bleibt in der
Liste, Suchmaschinen werten die Story als Original. Migration
news_story_canonical_20261110 setzt die 13 Zuordnungen (angewendet).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
orascheandClaude Fable 5.1 committed 2026-11-10 18:20:03 +01:00
1 parent f7b1eacecb
commit 4b6731786d
4 files changed
+135

No files matched your search

@@ -67,6 +67,7 @@ class VitecMetaHandler extends MetaHandler
$title = trim((string)($content['seo']['title'] ?? ''));
$description = '';
$image = '';
$canonicalPath = '';
// --- record context -------------------------------------------------
$newsUid = (int)($args['tx_news_pi1']['news'] ?? 0);
@@ -90,6 +91,15 @@ class VitecMetaHandler extends MetaHandler
);
}
$image = $this->firstImage('tx_news_domain_model_news', 'fal_media', $newsUid);
// Same text as a success story: the story is the original.
$storyUid = (int)($news['vitec_canonical_usecase'] ?? 0);
if ($storyUid > 0) {
$story = $this->fetchRow('tx_vitec_domain_model_usecase', ['uid' => $storyUid]);
$storySlug = trim((string)($story['slug'] ?? ''));
if ($storySlug !== '') {
$canonicalPath = '/success-stories/' . $storySlug;
}
}
}
} elseif ($productArg !== '') {
$product = is_numeric($productArg)
@@ -227,6 +237,23 @@ class VitecMetaHandler extends MetaHandler
}
}
// --- news article whose canonical is a success story --------------------
if ($canonicalPath !== '') {
$href = $this->absolute($canonicalPath, $base);
$links = is_array($content['seo']['link'] ?? null) ? $content['seo']['link'] : [];
$replaced = false;
foreach ($links as $index => $link) {
if (($link['rel'] ?? '') === 'canonical') {
$links[$index]['href'] = $href;
$replaced = true;
}
}
if (!$replaced) {
$links[] = ['href' => $href, 'rel' => 'canonical'];
}
$content['seo']['link'] = $links;
}
return $content;
}