Use proper html output for AMP pages
authorAlexander Ebert <ebert@woltlab.com>
Thu, 28 Jul 2016 10:40:22 +0000 (12:40 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 28 Jul 2016 10:40:22 +0000 (12:40 +0200)
com.woltlab.wcf/templates/ampArticle.tpl
wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php

index 9ce2344d8e0b26fe053763fb72bd6b94cb845602..f4bcbdc8b8645763a60e0ca025fac448b6346b82 100644 (file)
@@ -61,7 +61,7 @@
        {/if}
        
        <div class="articleContent">
-               {@$articleContent->getFormattedContent()}
+               {@$articleContent->getAmpFormattedContent()}
        </div>
 </article>
 
index 05dfd77627c78948f16879d7b5b574c383b97cd1..042e3d671a1eae2944647ee75e9dd11269b3f91b 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\article\Article;
 use wcf\data\language\Language;
 use wcf\data\DatabaseObject;
 use wcf\data\ILinkableObject;
+use wcf\system\html\output\AmpHtmlOutputProcessor;
 use wcf\system\html\output\HtmlOutputProcessor;
 use wcf\system\language\LanguageFactory;
 use wcf\system\request\IRouteController;
@@ -98,6 +99,18 @@ class ArticleContent extends DatabaseObject implements ILinkableObject, IRouteCo
                return $processor->getHtml();
        }
        
+       /**
+        * Returns the article's formatted content ready for use with Google AMP pages.
+        * 
+        * @return      string
+        */
+       public function getAmpFormattedContent() {
+               $processor = new AmpHtmlOutputProcessor();
+               $processor->process($this->content, 'com.woltlab.wcf.article.content', $this->articleContentID);
+               
+               return $processor->getHtml();
+       }
+       
        /**
         * Returns article object.
         *