typo3rsstypo3-9.xrss2

How to implement a TYPO3 9.5 RSS Feed for Pages


I researched a bit but was not able to find a fitting solution. The problem is quite simple we just need to output an RSS feed for our custom blog pages.

We have a blog page and the child pages are the actual blog records so to speak - other periphere systems require that structure. Now my question is what would be the approach within TYPO3 to actually generate RSS feeds for every of those child pages?

Any help is much appreciated.


Solution

  • plugin.tx_seo {
        view {
            templateRootPaths {
                20 = EXT:ds_site/Resources/Private/Templates/Sitemaps/
            }
        }
        config {
            xmlSitemap {
                sitemaps {
                    rssFeedAllBlogPosts {
                        provider = TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider
                        config {
                            table = pages
                            sortField = tstamp
                            lastModifiedField = tstamp
                            additionalWhere = AND (no_index = 0 OR no_follow = 0)
                            pid = 2
                            recursive = 3
                            template = RssFeed
                        }
                    }
                }
            }
        }
    }
    

    version="1.0" encoding="UTF-8" ?>
    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
        <channel>
            <title>Daniel Siepmann - Coding is Art</title>
            <description>List of blog posts at daniel-siepmann.de</description>
            <link>{f:uri.page(pageUid: 1, absolute: 1)}</link>
            <atom:link href="{f:uri.page(pageUid: 1. pageType: 1533906435, additionalParams: {sitemap: 'rssFeedAllBlogPosts'}, absolute: 1)}" rel="self" type="application/rss+xml" />
            <lastBuildDate>{f:format.date(date: 'now', format: 'D, d M Y H:i:s O')}</lastBuildDate>
            <ttl>1800</ttl>
    
            <f:for each="{items}" as="item">
                <f:if condition="{item.data.doktype} < 200">
                    {f:render(section: 'Item', arguments: {
                        item: item.data
                    })}
                </f:if>
            </f:for>
        </channel>
    </rss>
    
    <f:section name="Item">
        <item>
            <title>{item.title}</title>
            <description>{item.abstract}</description>
            <link>{f:uri.page(pageUid: item.uid, absolute: 1)}</link>
            <pubDate>{f:format.date(date: item.lastUpdated, format: 'D, d M Y H:i:s O')}</pubDate>
            <guid isPermaLink="true">{f:uri.page(pageUid: item.uid, absolute: 1)}</guid>
        </item>
    </f:section>
    

    You can use this one as a reference implementation. That's what I use for my website. Of course you need to adjust it accordingly, e.g. pid might be different, as well as extension key ds_site, etc.

    Also note, this one uses EXT:seo, a system extension of TYPO3, providing sitemap features.

    You can link to the feed: <a href="{f:uri.page(pageUid: 1, pageType: 1533906435, additionalParams: {sitemap: 'rssFeedAllBlogPosts'})}">RSS Feed</a>.

    Also you might wanna adjust url routing:

    routeEnhancers:
      PageTypeSuffix:
        type: PageType
        default: .html
        map:
          .xml: 1533906435
          .html: 0
      Feed:
        type: Simple
        limitToPages:
          - 1
        routePath: '/feed/{sitemap_id}'
        requirements:
          sitemap_id: '[a-zA-Z].*'
        _arguments:
          sitemap: sitemap_id