Added metag tags for cms pages
authorMarcel Werk <burntime@woltlab.com>
Tue, 28 Jun 2016 21:05:39 +0000 (23:05 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 28 Jun 2016 21:05:39 +0000 (23:05 +0200)
wcfsetup/install/files/lib/page/CmsPage.class.php

index 80f2e28f67988332c5b6905f02058539bb790d5c..7232fd0c9df5e390c4db13198ba2d51b1468bca8 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\page;
 use wcf\data\page\Page;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\language\LanguageFactory;
+use wcf\system\MetaTagHandler;
 use wcf\system\request\LinkHandler;
 use wcf\system\request\RequestHandler;
 use wcf\system\WCF;
@@ -80,6 +81,24 @@ class CmsPage extends AbstractPage {
                }
        }
        
+       /**
+        * @inheritDoc
+        */
+       public function readData() {
+               parent::readData();
+               
+               // add meta/og tags
+               MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->content['title'] . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true);
+               MetaTagHandler::getInstance()->addTag('og:url', 'og:url', $this->canonicalURL, true);
+               MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'website', true);
+               if ($this->content['metaDescription']) {
+                       MetaTagHandler::getInstance()->addTag('og:description', 'og:description', $this->content['metaDescription'], true);
+               }
+               if ($this->content['metaKeywords']) {
+                       MetaTagHandler::getInstance()->addTag('keywords', 'keywords', $this->content['metaKeywords']);
+               }
+       }
+       
        /**
         * @inheritDoc
         */