Automatic RSS Feeds¶
Sometimes it is nice/required to render RSS feeds of news list views without any extra pages or configuration.
Therefore any editor can create a new page with a list plugin and the feed will contain the same configuration and therfore the same news records
TypoScript-Code¶
1 [globalVar = TSFE:type = 9818]
2 lib.stdheader >
3 tt_content.stdWrap.innerWrap >
4 tt_content.stdWrap.wrap >
5 # get away <div class="feEditAdvanced-firstWrapper" ...> if your logged into the backend
6 styles.content.get.stdWrap >
7
8 pageNewsRSS = PAGE
9 pageNewsRSS.typeNum = 9818
10 pageNewsRSS.10 < styles.content.get
11 pageNewsRSS.10.select.where = colPos=0 AND list_type = "news_pi1"
12 pageNewsRSS.10.select {
13 orderBy = sorting ASC
14 max = 1
15 }
16
17 config {
18 # deactivate Standard-Header
19 disableAllHeaderCode = 1
20 # no xhtml tags
21 xhtml_cleaning = none
22 admPanel = 0
23 metaCharset = utf-8
24 # you need an english locale to get correct rfc values for <lastBuildDate>, ...
25 locale_all = en_EN
26 # define charset
27 additionalHeaders = Content-Type:text/xml;charset=utf-8
28 disablePrefixComment = 1
29 baseURL = http://www.domain.tld/
30 absRefPrefix = http://www.domain.tld/
31 }
32
33 # set the format
34 plugin.tx_news.settings.format = xml
35 [global]
Explanation
- Some wraps of css_styled_content are removed, the same for a possible header because this should not appear in RSS output
- A new page type with typeNum = 9818 is created and renders the first news plugin which is found in colPos = 0. Therefore it is no problem to have other content elements on the same page.
- A little configuration is needed to create valid code
RealURL Configuration¶
To get some nicer URLS, you can add this to your RealURL configuration
1 'fileName' => array(
2 'defaultToHTMLsuffixOnPrev' => TRUE,
3 'index' => array(
4 'feed.rss' => array(
5 'keyValues' => array(
6 'type' => 9818,
7 )
8 ),
9 ),
10 ),
Explanation
If the normal url would be www.domain.tld/fo/bar/my-newslist.html, the generated url would be www.domain.tld/fo/bar/my-newslist/feed.rss
Add correct tag to the page header¶
Last optional thing is to add the link to the feed to the normal page. After this, a feed reader can automatically grab your RSS feed url from the source code you can use the dynamic bookmark feature of your browser. Add this to the List.html
1 <n:headerData><link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<f:uri.page additionalParams="{type:9818}"/>" /></n:headerData>