From 788d7fdb588bd607214865fc90cd3a29ede96597 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Sun, 4 Apr 2021 17:02:20 +0200 Subject: [PATCH] Add meta tags for CategoryArticleListPage --- .../page/CategoryArticleListPage.class.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/wcfsetup/install/files/lib/page/CategoryArticleListPage.class.php b/wcfsetup/install/files/lib/page/CategoryArticleListPage.class.php index 9bab3f74e8..10271a2162 100644 --- a/wcfsetup/install/files/lib/page/CategoryArticleListPage.class.php +++ b/wcfsetup/install/files/lib/page/CategoryArticleListPage.class.php @@ -6,9 +6,11 @@ use wcf\data\article\category\ArticleCategory; use wcf\data\article\CategoryArticleList; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\PermissionDeniedException; +use wcf\system\MetaTagHandler; use wcf\system\page\PageLocationManager; use wcf\system\request\LinkHandler; use wcf\system\WCF; +use wcf\util\StringUtil; /** * Shows a list of cms articles in a certain category. @@ -122,6 +124,32 @@ class CategoryArticleListPage extends ArticleListPage $parentCategory ); } + + // Add meta tags. + MetaTagHandler::getInstance()->addTag( + 'og:title', + 'og:title', + $this->category->getTitle() . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), + true + ); + MetaTagHandler::getInstance()->addTag( + 'og:url', + 'og:url', + $this->category->getLink(), + true + ); + if ($this->category->getDescription()) { + $description = $this->category->getDescription(); + if ($this->category->descriptionUseHtml) { + $description = StringUtil::decodeHTML(StringUtil::stripHTML($description)); + } + MetaTagHandler::getInstance()->addTag( + 'og:description', + 'og:description', + $description, + true + ); + } } /** -- 2.20.1