TYPO3: tt_news Atom feed with images

tt_news is the standard extension in TYPO3 to display news lists and items. It's easily extendable and has a ton of features, including feed generation.

When creating neatful.de, the requirement was to supply a feed with links to the latest projects on the site, together with some project images. The news feed is updated manually - automatically was an option first, but using the latest change date on a page would also mean that an old page would get listed on the feed if you just fixed a typo on it.

I came across several problems when creating the feed:

The content header problem was fixed easily with

xmlnews.config.additionalHeaders = Content-Type: application/atom+xml

The problem in my case was that the feed is available under

http://www.neatful.de/feed/

and image links are generated relative and with the expectation that the page URL is a file in the root directory, i.e. index.php?id=23:

typo3temp/pics/152f637f34.jpg

This is a well known issue that is easily fixed in HTML by adding a base URL to the <head>. This is unfortunately not possible in a feed.

A solution?

I found a dozen pages that recommended the following:

That TypoScript code makes image src attributes absolute - when the images are inserted in the text of the RTE. Since the "normal" media file integration is used in my case, this did not help.

A patch for tt_news

The correct way to solve the relative image problem is to set config.absRefPrefix to the domain name, http://www.neatful.de/ in my case.

I did that and got correct image URLs! Unfortunately, tt_news did now break the detail links by double-prefixing them with the domain again, leading to links like http://www.neatful.de/http://www.neatful.de/sticking/.

At first I thought I did something wrong, but then found out that tt_news version 3.0.1 simply contains a to that date unknown bug. A fix was easily implemented, and so I opened bug #17458 in the TYPO3 bug tracker and attached my patch.

Example

In case someone is interested in the News feed configuration, here it is:

news.ts

tt_news-atom-1.0.tmpl

###XML_DECLARATION###

 
 ###SITE_TITLE###
 
  neatful
   hello@neatful.de
 
 
 
 
 
 ###SITE_LINK###
 ###NEWS_LASTBUILD###
 TYPO3 - get.content.right
 ###SITE_DESCRIPTION###
 ###NEWS_COPYRIGHT###  
 
 
   
 
  ###NEWS_TITLE###
  
  ###NEWS_MODIFIED###
  ###NEWS_CREATED###
  ###NEWS_ATOM_ENTRY_ID###
  

###NEWS_SUBHEADER###

###NEWS_IMAGE###

see more of it

]]>

Written by Christian Weiske.

Comments? Please send an e-mail. Or Reply or Like.