diff --git a/Classes/Frontend/RssFeed/ContentRendering.php b/Classes/Frontend/RssFeed/ContentRendering.php new file mode 100644 index 0000000..c07740e --- /dev/null +++ b/Classes/Frontend/RssFeed/ContentRendering.php @@ -0,0 +1,64 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +namespace DanielSiepmann\DsSite\Frontend\RssFeed; + +use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; + +class ContentRendering +{ + public function __construct( + private readonly ContentObjectRenderer $contentObjectRenderer + ) { + } + + public function extend(array $row): array + { + $row['description'] = $row['data']['abstract'] . $this->getContent($row['data']['uid']); + return $row; + } + + private function getContent(int $pageUid): string + { + $colPositions = [ + 50, + 0, + 100, + 200, + ]; + + $content = ''; + foreach ($colPositions as $colPos) { + $content .= $this->contentObjectRenderer->cObjGetSingle('CONTENT', [ + 'table' => 'tt_content', + 'select.' => [ + 'orderBy' => 'sorting', + 'where' => '{#colPos}=' . $colPos, + 'pidInList' => $pageUid, + ], + ]); + } + + return $content; + } +} diff --git a/Classes/Frontend/RssFeed/SitemapDataProvider.php b/Classes/Frontend/RssFeed/SitemapDataProvider.php index acdb72a..d7adf47 100644 --- a/Classes/Frontend/RssFeed/SitemapDataProvider.php +++ b/Classes/Frontend/RssFeed/SitemapDataProvider.php @@ -54,6 +54,16 @@ class SitemapDataProvider extends RecordsXmlSitemapDataProvider parent::__construct($request, $key, $config, $cObj); } + public function generateItems(): void + { + parent::generateItems(); + + $contentRendering = new ContentRendering($this->cObj); + foreach ($this->items as $key => $item) { + $this->items[$key] = $contentRendering->extend($item); + } + } + private function getPageUidsWithRelationToCategory(int $categoryUid): array { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) diff --git a/Resources/Private/Templates/Sitemaps/RssFeed.xml b/Resources/Private/Templates/Sitemaps/RssFeed.xml index 2c5b0f7..b151360 100644 --- a/Resources/Private/Templates/Sitemaps/RssFeed.xml +++ b/Resources/Private/Templates/Sitemaps/RssFeed.xml @@ -21,7 +21,8 @@ {f:render(section: 'Item', arguments: { - item: item.data + item: item.data, + description: item.description })} @@ -31,7 +32,7 @@ {item.title} - {item.abstract} + {description -> f:format.cdata()} {f:uri.typolink(parameter: 't3://page?uid={item.uid}', absolute: 1)} {f:format.date(date: item.lastUpdated, format: 'D, d M Y H:i:s O')} {f:uri.typolink(parameter: 't3://page?uid={item.uid}', absolute: 1)}