diff --git a/Classes/Frontend/RssFeed/SitemapDataProvider.php b/Classes/Frontend/RssFeed/SitemapDataProvider.php
new file mode 100644
index 0000000..8b1c656
--- /dev/null
+++ b/Classes/Frontend/RssFeed/SitemapDataProvider.php
@@ -0,0 +1,99 @@
+
+ *
+ * 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.
+ */
+
+use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Core\Database\Connection;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryBuilder;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
+use TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider;
+
+/**
+ * Provides dynamic for additionalWhere,
+ * to only list pages for current requested category.
+ */
+class SitemapDataProvider extends RecordsXmlSitemapDataProvider
+{
+ public function __construct(
+ ServerRequestInterface $request,
+ string $key,
+ array $config = [],
+ ContentObjectRenderer $cObj = null
+ ) {
+ $categoryUid = intval($request->getQueryParams()['category'] ?? 0);
+ if ($categoryUid > 0) {
+ $pageUids = $this->getPageUidsWithRelationToCategory($categoryUid);
+ $config['additionalWhere'] = ($config['additionalWhere'] ?? '')
+ . $this->createAdditionalWhereForPageUids($pageUids)
+ ;
+ }
+
+ parent::__construct($request, $key, $config, $cObj);
+ }
+
+ private function getPageUidsWithRelationToCategory(int $categoryUid): array
+ {
+ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+ ->getQueryBuilderForTable('pages');
+ /* @var QueryBuilder $queryBuilder */
+
+ $queryBuilder->select('uid');
+ $queryBuilder->from('pages');
+ $queryBuilder->leftJoin(
+ 'pages',
+ 'sys_category_record_mm',
+ 'mm',
+ 'pages.uid = mm.uid_foreign'
+ );
+ $queryBuilder->where(
+ $queryBuilder->expr()->eq(
+ 'mm.tablenames',
+ $queryBuilder->createNamedParameter('pages')
+ ),
+ $queryBuilder->expr()->eq(
+ 'mm.fieldname',
+ $queryBuilder->createNamedParameter('categories')
+ ),
+ $queryBuilder->expr()->in(
+ 'mm.uid_local',
+ $queryBuilder->createNamedParameter($categoryUid)
+ )
+ );
+
+ $result = $queryBuilder->execute()->fetchAll();
+ if ($result === false) {
+ return [];
+ }
+
+ return array_map(function (array $row) {
+ return (int) $row['uid'];
+ }, $result);
+ }
+
+ private function createAdditionalWhereForPageUids(array $pageUids): string
+ {
+ return ' AND uid IN(' . implode(',', $pageUids) . ')';
+ }
+}
diff --git a/Classes/Frontend/RssFeed/XmlSitemapRenderer.php b/Classes/Frontend/RssFeed/XmlSitemapRenderer.php
new file mode 100644
index 0000000..b607edb
--- /dev/null
+++ b/Classes/Frontend/RssFeed/XmlSitemapRenderer.php
@@ -0,0 +1,50 @@
+
+ *
+ * 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.
+ */
+
+use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
+use TYPO3\CMS\Seo\XmlSitemap\XmlSitemapRenderer as Typo3XmlSitemapRenderer;
+
+class XmlSitemapRenderer extends Typo3XmlSitemapRenderer
+{
+ /**
+ * @var ContentObjectRenderer
+ */
+ public $cObj;
+
+ public function render(string $_, array $typoScriptConfiguration): string
+ {
+ $settings = [];
+ foreach (array_keys($typoScriptConfiguration['userFunc.']['variables.'] ?? []) as $variableName) {
+ if (substr($variableName, -1) === '.') {
+ continue;
+ }
+ $settings[$variableName] = $this->cObj->cObjGetSingle(
+ $typoScriptConfiguration['userFunc.']['variables.'][$variableName] ?? '',
+ $typoScriptConfiguration['userFunc.']['variables.'][$variableName . '.'] ?? []
+ );
+ }
+ $this->view->assign('settings', $settings);
+
+ return parent::render($_, $typoScriptConfiguration);
+ }
+}
diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml
index 64457bb..d7003a1 100644
--- a/Configuration/Services.yaml
+++ b/Configuration/Services.yaml
@@ -30,7 +30,7 @@ services:
$view: '@dashboard.views.widget'
$cache: '@cache.dashboard.rss'
$options:
- feedUrl: 'https://daniel-siepmann.de/feed/rssFeedAllBlogPosts/sitemap.xml'
+ feedUrl: 'https://daniel-siepmann.de/rss-feed/blog-posts.xml'
limit: 3
tags:
- name: dashboard.widget
diff --git a/Configuration/TypoScript/Setup/RssFeed.typoscript b/Configuration/TypoScript/Setup/RssFeed.typoscript
index 776ab32..f292274 100644
--- a/Configuration/TypoScript/Setup/RssFeed.typoscript
+++ b/Configuration/TypoScript/Setup/RssFeed.typoscript
@@ -7,8 +7,8 @@ plugin.tx_seo {
config {
xmlSitemap {
sitemaps {
- rssFeedAllBlogPosts {
- provider = TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider
+ blog-posts {
+ provider = DanielSiepmann\DsSite\Frontend\RssFeed\SitemapDataProvider
config {
table = pages
sortField = lastUpdated
@@ -31,9 +31,57 @@ page {
wrap =
typolink {
parameter = t3://page?uid=1
- additionalParams = &type=1533906435&sitemap=rssFeedAllBlogPosts
+ additionalParams = &type=1533906435&sitemap=blog-posts
returnLast = url
}
}
+ 11 = COA
+ 11 {
+ if {
+ isTrue.stdWrap.data = GP:topic_id
+ }
+ 1 = TEXT
+ 1.char = 10
+ 2 = TEXT
+ 2 {
+ noTrimWrap = |
+ typolink {
+ parameter = t3://page?uid=1
+ additionalParams.stdWrap.cObject = COA
+ additionalParams.stdWrap.cObject {
+ 10 = TEXT
+ 10.value = &type=1533906435&sitemap=blog-posts
+ 11 = TEXT
+ 11.value = &category=
+ 12 = TEXT
+ // uid is casted to int within PHP source
+ 12.data.dataWrap = DB : sys_category:{GP:topic_id}:uid
+ }
+ returnLast = url
+ }
+ }
+ }
+ }
+}
+
+seo_sitemap {
+ 10 {
+ userFunc = DanielSiepmann\DsSite\Frontend\RssFeed\XmlSitemapRenderer->render
+ userFunc {
+ variables {
+ categoryId = TEXT
+ categoryId.data = GP:category
+ categoryId.intval = 1
+ categoryTitle = TEXT
+ categoryTitle.data.dataWrap = DB : sys_category:{GP:category}:title
+ }
+ }
}
}
diff --git a/Resources/Private/Partials/Page/FooterMenu.html b/Resources/Private/Partials/Page/FooterMenu.html
index b763006..f981150 100644
--- a/Resources/Private/Partials/Page/FooterMenu.html
+++ b/Resources/Private/Partials/Page/FooterMenu.html
@@ -1,7 +1,7 @@