tt_news RSS feed – valid and with images
I struggled some hours to get a RSS feed from tt_news including images. It appeared to be quiet simple. One of the problems was after inserting the NEWS_IMAGE marker in de template that the path in the source was only relative. An absRefPrefix with the baseURL seems to fix this. The template also needed some altering to get it through the W3 validator.
After you set up a working tt_news (3.0.1) :
Note : replace or declare the constants like $newsFolder for the corresponding values, page id’s and paths
Typoscript setup
plugin.tt_news {
displayXML {
rss2_tmplFile = {$tmplpath}tt_news_rss_2.tmpl
xmlFormat = rss2
xmlTitle = {$title} - latest news
xmlLink = {$baseURL}newsarchive/
xmlDesc = {$slogan}
xmlLang = nl
xmlIcon = fileadmin/templates/img/siteLogoRSS.gif
title_stdWrap.htmlSpecialChars = 1
title_stdWrap.htmlSpecialChars.preserveEntities = 1
subheader_stdWrap.stripHtml = 1
subheader_stdWrap.htmlSpecialChars = 1
subheader_stdWrap.htmlSpecialChars.preserveEntities = 1
subheader_stdWrap.crop = 300 | ... | 1
subheader_stdWrap.ifEmpty.field = bodytext
xmlLastBuildDate = 1
xmlLimit = 10
image.file.maxW = 180c
# images in rss tmpl
showImages = 1
}
}
xmlnews = PAGE
xmlnews {
typeNum = 100
10 >
10 < plugin.tt_news
10.pid_list >
10.pid_list = {$newsFolder}
10.singlePid = {$newsArticle}
10.defaultCode = XML
#10.categoryMode = 1
#10.categorySelection = 1 # would show only category 1
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:text/xml
no_cache = 1
xhtml_cleaning = 0
}
}
[globalVar = GP:type = 100]
#URL prefix for images in feed
config.absRefPrefix = {$baseURL}
config.baseURL =
[global]
## RSS button in for example address bar in Firefox < version 4, what happened to RSS button in 4+ ?? :S
#page.headerData.12 = TEXT
#page.headerData.12.value = <link rel="alternate" type="application/rss+xml" title="{$title}: latest news" href="{$baseURL}newsarchive/rss.xml">
Template tt_news_rss_2.tmpl
It is assumed here you have the tt_news archive in /newsarchive :
<!-- ###TEMPLATE_RSS2### begin -->###XML_DECLARATION### <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" > <channel> <!-- ###HEADER### begin --> <title>###SITE_TITLE###</title> <atom:link href="###SITE_LINK###newsarchive/rss.xml" rel="self" type="application/rss+xml" /> <link>###SITE_LINK###</link> <description>###SITE_DESCRIPTION###</description> ###SITE_LANG### <image> <title>###SITE_TITLE###</title> <url>###IMG###</url> <link>###SITE_LINK###</link> <description>###SITE_DESCRIPTION###</description> </image> <generator>TYPO3 - get.content.right</generator> <docs>http://blogs.law.harvard.edu/tech/rss</docs> ###NEWS_COPYRIGHT### ###NEWS_WEBMASTER### ###NEWS_MANAGINGEDITOR### ###NEWS_LASTBUILD### <!-- ###HEADER### end --> <!-- ###CONTENT### begin --> <!-- ###NEWS### begin --> <item> <title>###NEWS_TITLE###</title> <link>###NEWS_LINK###</link> <description><![CDATA[###NEWS_SUBHEADER###]]> <![CDATA[<p></p>]]><![CDATA[###NEWS_IMAGE###]]> <![CDATA[###NEWS_CONTENT###]]></description> ###NEWS_CATEGORY### <guid>###NEWS_LINK###</guid> <pubDate>###NEWS_DATE###</pubDate> ###NEWS_RSS2_ENCLOSURES### </item> <!-- ###NEWS### end --> <!-- ###CONTENT### end --> </channel> </rss><!-- ###TEMPLATE_RSS2### end -->
