RSS and Atom Feeds

This article explains how generating RSS or Atom feeds based on the content of recently updated pages. I am using the extension  ecorss from Fabien Udriot as I just found it nice and I actively contributed to it in February 2008.

Specifications

As a concrete example, I wish to generate 2 newsfeeds for two distinct topics on my website, namely LaTeX and TYPO3 tutorials. The structure of pages I have is as follows:

Tutorials
|-- TYPO3
| |-- page 1
| `-- page 2
`-- LaTeX
|-- page 1
|-- page 2
`-- page 3

and I wish to be notified with a RSS / Atom feed whenever an article has been updated in one of those topics.

In addition, I want the feeds to be localized the same way my pages are. That is, as I have a French and an English version of my TYPO3 tutorials, I want to get localized feeds as well.

Preparing the Environment

Let’s start installing dependencies of the extension ecorss, that is:

  1.  div : Static Methods for Extensions
  2.  lib : Library for Extensions

At this point we may install the extension  ecorss. Then, an essential step is to include it as a static extension in our Template, the way it is described in the extension’s documentation.

Configuring the Extension

In Template TS, we will configure two Atom feeds with the latest 10 updates for topic TYPO3 and topic LaTeX. The landing-page of TYPO3 has id 13, while the one of LaTeX has id 9.

plugin.tx_ecorss.feed = atom
 
page.headerData.12 = USER
page.headerData.12.userFunc = tx_ecorss_controllers_feed->add
 
	# Feed for TYPO3 news
page.headerData.12.feed1{
	title = Tutoriels TYPO3
	typeNum = 122
	url = news-typo3.xml
}
 
	# Feed for LaTeX news
page.headerData.12.feed2{
	title = Tutoriels LaTeX
	typeNum = 123
	url = news-latex.xml
}

With TYPO3 news, a French translation is available (in fact this is the default language, English being set with L = 1), and as such we would like to propose it automatically to French visitor.

[globalVar = GP:L=1]
 
	# Feed for TYPO3 news
page.headerData.12.feed1 {
	title = TYPO3 Tutorials (English)
	typeNum = 124
	url = news-typo3-en.xml
}
 
[global]

The last step is to finalize the configuration of our different feeds.

	# TYPO3 Feed Configuration
feed1 = PAGE
feed1 {
	typeNum = 122
 
	10 >
	10 = USER
	10 {
		encoding = iso-8859-1
		userFunc = tx_ecorss_controllers_feed->display
		lang = fr-FR
		sysLanguageUid = 0
 
		numberItems = 10
		pidRootline = 13
 
		title = TYPO3
		subtitle = Résumé des modifications dans les tutoriels TYPO3
	}
 
	config {
		disableAllHeaderCode = 1
		additionalHeaders = Content-type:text/xml
		no_cache = 1
		xhtml_cleaning = 0
		admPanel = 0
		disableCharsetHeader = 1
	}
}
 
	# LaTeX Feed Configuration
feed2 < feed1
feed2 {
	typeNum = 123
	10 {
		pidRootline = 9
		title = LaTeX
		subtitle = Résumé des modifications dans les tutoriels LaTeX
	}
}
 
	# TYPO3 English Feed Configuration
feed3 < feed1
feed3 {
	typeNum = 124
	10 {
		lang = en-GB
		sysLanguageUid = 1
		subtitle = Modification Summary of TYPO3 Tutorials
	}
}

Configuring RealURL

We configured ecorss in order to generate feeds with names news-typo3.xml, news-latex.xml and news-typo3-en.xml for feeds whose typeNum are 122, 123 and 124 respectively. We thus have to update the RealURL configuration:

, 'fileName' => array (
        'index' => array(
                 'index.html' => array(
                        'keyValues' => array(
                                'type' => 0,
                        )
                )
                , 'news-typo3.xml' => array(
                        'keyValues' => array(
                                'type' => 122,
                        )
                )
                , 'news-latex.xml' => array(
                        'keyValues' => array(
                                'type' => 123,
                        )
                )
                , 'news-typo3-en.xml' => array(
                        'keyValues' => array(
                                'type' => 124,
                        )
                )
                , '_DEFAULT' => array(
                        'keyValues' => array()
                )
        )

We may now check that our feed is valid using  http://feedvalidator.org/

Flattr