Add full blog post to feed

This commit is contained in:
Daniel Siepmann 2023-08-03 22:14:33 +02:00
parent bf660d15fc
commit 047832acbb
3 changed files with 77 additions and 2 deletions

View file

@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/*
* Copyright (C) 2023 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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;
}
}

View file

@ -54,6 +54,16 @@ class SitemapDataProvider extends RecordsXmlSitemapDataProvider
parent::__construct($request, $key, $config, $cObj); 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 private function getPageUidsWithRelationToCategory(int $categoryUid): array
{ {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)

View file

@ -21,7 +21,8 @@
<f:for each="{items}" as="item"> <f:for each="{items}" as="item">
<f:if condition="{item.data.doktype} < 200"> <f:if condition="{item.data.doktype} < 200">
{f:render(section: 'Item', arguments: { {f:render(section: 'Item', arguments: {
item: item.data item: item.data,
description: item.description
})} })}
</f:if> </f:if>
</f:for> </f:for>
@ -31,7 +32,7 @@
<f:section name="Item"> <f:section name="Item">
<item> <item>
<title>{item.title}</title> <title>{item.title}</title>
<description>{item.abstract}</description> <description>{description -> f:format.cdata()}</description>
<link>{f:uri.typolink(parameter: 't3://page?uid={item.uid}', absolute: 1)}</link> <link>{f:uri.typolink(parameter: 't3://page?uid={item.uid}', absolute: 1)}</link>
<pubDate>{f:format.date(date: item.lastUpdated, format: 'D, d M Y H:i:s O')}</pubDate> <pubDate>{f:format.date(date: item.lastUpdated, format: 'D, d M Y H:i:s O')}</pubDate>
<guid isPermaLink="true">{f:uri.typolink(parameter: 't3://page?uid={item.uid}', absolute: 1)}</guid> <guid isPermaLink="true">{f:uri.typolink(parameter: 't3://page?uid={item.uid}', absolute: 1)}</guid>