Login / Status
developer.Resource
Home . Documentation . Document Library . Extension Manuals
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

Chapter 1. EXT: RSS feed

Extension Key: ecorss

Copyright 2006-2008, Ecodev, <fabien.udriot@ecodev.ch>

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.com

1.1. Introduction

What does it do?

This extension is designed to set up quickly and easily one or many rss feeds from any tables of the database. Copy / paste a few TypoScript lines in your template setup and that's it ! You can follow the latest content of your website – keep an eye on the latest frontend user etc...

features :

  1. choose whether ATOM or RSS feed is displayedhttp://en.wikipedia.org/wiki/Atom_(standard) http://en.wikipedia.org/wiki/RSS_(file_format)

  2. Extract value from flexform (requires MySQL 5.2). Some values can be stored in flexform data. This information is not very practical to extract. However with MySQL 5.2, it is now possible to build XPath requests and fetch data within the XML structures.

  3. Hide / show several different feeds on the same pages. RSS feeds are very practical to follow the life of a website. You can imagine a feed that inform you whether a new page is created, a backend user's profile has been updated or a content element has been updated. Such administrative feeds are not necessarily shown in the frontend but are given only for administrators.

  4. A lot of possible data combination and configurations...

further documentation of RSS :

http://www.rssboard.org/rss-specification

No screenshots necessary !

@see rather the TypoScript example in the next section.

Installation

Download and install the extension as normal. No database update necessary.

Update your "Static Include" from extension by editing the main template (module Web > List) as follows:

How to build a feed, TypoScript example

Very Important: this extension won't work until you properly complete the installation section.

Secondly, the example bellow are not well formated in the HTML documentation. See the OpenOffice document for a nice indentation or to copy / paste into the Setup Template.

0) Express installation, copy / paste these lines into a template > setup

###############################

# DECLARE FEED (ATOM)

###############################

page.headerData.12 = USER

page.headerData.12.userFunc = tx_ecorss_controllers_feed->add

page.headerData.12.feed1{

title = title of the feed

subtitle = subtitle of the feed

typeNum = 122

url = index.php?type=122

}

###############################

# GENERATE THE FEED

###############################

feed1 = PAGE

feed1 {

typeNum = 122

10 >

10 = USER

10.userFunc = tx_ecorss_controllers_feed->display

10.lang = fr-FR

10.title = title of the feed

10.subtitle = subtitle of the feed

config{

disableAllHeaderCode = 1

disableCharsetHeader = 1

additionalHeaders = Content-type:text/xml

no_cache = 1

xhtml_cleaning = 0

admPanel = 0

}

}

1) more detail: declare a RSS or ATOM feed in the frontend

# declare 1 feed. Copy paste these lines in a template > setup. An icon will appear in modern browsers    ;-)

page = PAGE

page.headerData.12 = USER

page.headerData.12.userFunc = tx_ecorss_controllers_feed->add

page.headerData.12.feed1{

title = Here comes the title of the feed

# correspond to the parameter type in the URL e.g http:://mysite.com/index.php?id=1&type=126

typeNum = 126

# correspond to the outputed URL

url = index.php?id=1&type=126

# with RealURL or CoolURI activated put something like => url = atom.xml

# default value "atom" - possible values (atom - rss)

# feed = atom

}

# declare 2 different feeds in the frontend. Copy paste these lines in a template > setup

page = PAGE

page.headerData.12 = USER

page.headerData.12.userFunc = tx_ecorss_controllers_feed->add

page.headerData.12.feed1{

title = Here comes the title of the feed

typeNum = 126

url = index.php?type=126

}

page.headerData.12.feed2{

title = Réseau Solidarité : les dossiers

typeNum = 127

url = index.php?type=127

}

PLUGIN GLOBAL CONFIGURATION

Property:

Data type:

Description:

Default:

num

int (mandatory)

the type of the page like index.php?id=1&type=126

null

url

string (mandatory)

the url in order to access the feed (display into the html header)

null

title

string

the title of the feed

feed

string

2 possibles values : atom – rss

have a look at the following links to know the difference of the formats :http://en.wikipedia.org/wiki/Atom_(standard) http://en.wikipedia.org/wiki/RSS_(file_format)

atom

IMPORTANT  REMARK: In case you have several feeds, you might want define constants to avoid repeating things.

# In the constant editor:

plugin.tx_ecorss.title = Here comes the *title* for every feeds

plugin.tx_ecorss.subtitle = Here comes the *subtitle* for every feeds

etc...

2) more detail: generate a RSS or ATOM feed

# The minimum configuration to build a feed. Copy paste these lines in a template > setup. It will display the latest updated content from table tt_content with 10 items

feed2 = PAGE

feed2 {

typeNum = 122

10 >

10 = USER

10.userFunc = tx_ecorss_controllers_feed->display

10.title = title of the feed

10.subtitle = subtitle of the feed

10.lang = fr-FR

config {

disableAllHeaderCode = 1

disableCharsetHeader = 1

additionalHeaders = Content-type:text/xml

no_cache = 1

xhtml_cleaning = 0

admPanel = 0

}

}

# It will provide exactly the same output as "feed2" but with more configuration

feed3 = PAGE

feed3 {

typeNum = 123

10 >

10 = USER

10.userFunc = tx_ecorss_controllers_feed->display

10.title = title of the feed

10.subtitle = subtitle of the feed

10.lang = fr-FR

10.numberItems = 10

10.feed = atom

10.select {

01 {

table = tt_content

title = header

summary = bodytext

published = tstamp

updated = tstamp

debug = 0

}

}

config {

disableAllHeaderCode = 1

disableCharsetHeader = 1

additionalHeaders = Content-type:text/xml

no_cache = 1

xhtml_cleaning = 0

admPanel = 0

}

}

# Only return entries for the language associated to L=1 (e.g., English)

feed4 = PAGE

feed4 {

typeNum = 124

10 >

10 = USER

10.userFunc = tx_ecorss_controllers_feed->display

10.title = title of the feed

10.subtitle = subtitle of the feed

10.lang = en-GB

10.sys_language_uid = 1

config {

disableAllHeaderCode = 1

disableCharsetHeader = 1

additionalHeaders = Content-type:text/xml

no_cache = 1

xhtml_cleaning = 0

admPanel = 0

}

}

# filter some record type from table tt_content.  

feed5 = PAGE

feed5 {

typeNum = 125

10 >

10 = USER

10.userFunc = tx_ecorss_controllers_feed->display

10.title = title of the feed

10.subtitle = subtitle of the feed

10.lang = fr-FR

10.select {

01 {

table = tt_content

# it will be transformed in SQL e.g. list_type=tx_ecobox_controllers_content

filterField = list_type

# comma separated value

filterInclude = tx_ecobox_controllers_content , tx_ecobox_controllers_box

}

}

config {

disableAllHeaderCode = 1

disableCharsetHeader = 1

additionalHeaders = Content-type:text/xml

no_cache = 1

xhtml_cleaning = 0

admPanel = 0

}

}

# include and exclude field's value in a more verbose configuration

feed6 = PAGE

feed6 {

typeNum = 126

10 >

10 = USER

10.userFunc = tx_ecorss_controllers_feed->display

10.title = title of the feed

10.subtitle = subtitle of the feed

10.lang = fr-FR

10.numberItems = 10

10.feed = atom

10.select {

01 {

table = tt_content

filterField = list_type

filterInclude = text, textpic

filterExclude = list, mailform

# the value corresponds to a field (title of the enty)

title = header

# the value corresponds to a field (body of the enty)

summary = bodytext

debug = 0

}

}

config {

disableAllHeaderCode = 1

disableCharsetHeader = 1

additionalHeaders = Content-type:text/xml

no_cache = 1

xhtml_cleaning = 0

admPanel = 0

}

}

# select content from a flexform (require MySQL 5.2)

feed7 = PAGE

feed7 {

typeNum = 127

10 >

10 = USER

10.userFunc = tx_ecorss_controllers_feed->display

10.title = title of the feed

10.subtitle = subtitle of the feed

10.lang = fr-FR

10.numberItems = 10

10.feed = rss

10.select{

01{

table = tt_content

filterField = list_type

filterInclude = tx_ecobox_controllers_content

# this option is not mandatory

summary = pi_flexform

summaryXPath = /T3FlexForms/data/sheet[@index="sSummary"]/language/field/value[text()]

}

}

config{

disableAllHeaderCode = 1

disableCharsetHeader = 1

additionalHeaders = Content-type:text/xml

no_cache = 1

xhtml_cleaning = 0

admPanel = 0

}

}

# select content from a flexform (require MySQL 5.2) AND combine with an other feed from an other table (pages)

feed8 = PAGE

feed8 {

typeNum = 128

10 >

10 = USER

10.userFunc = tx_ecorss_controllers_feed->display

10.title = title of the feed

10.subtitle = subtitle of the feed

10.lang = fr-FR

10.numberItems = 10

10.select {

01 {

table = tt_content

filterField = list_type

filterInclude = tx_ecobox_controllers_content

summaryXPath = /T3FlexForms/data/sheet[@index="sSummary"]/language/field/value[text()]

}

02 {

table = pages

title = title

summary = subtitle

published = crdate

updated = tstamp

debug = 0

}

}

config {

disableAllHeaderCode = 1

disableCharsetHeader = 1

additionalHeaders = Content-type:text/xml

no_cache = 1

xhtml_cleaning = 0

admPanel = 0

}

}

FEED CONFIGURATION

Property:

Data type:

Description:

Default:

title

string

the title of the feed

atom

subtitle

string

the subtile of the feed

lang

string

the character enconding : fr-FR ; de-DE ; en-US

en-GB

host

string

define an other host name t if not the same as $_SERVER['HTTP_HOST'].

$_SERVER['HTTP_HOST']

encoding

string

utf-8

numberItems

string

number of elements in the feed

10

feed

string

2 possibles values : atom ; rss

have a look at the following links to know the difference of the formats :http://en.wikipedia.org/wiki/Atom_(standard)http://en.wikipedia.org/wiki/RSS_(file_format)

atom

author.name

string

the author of the feed's (Atom feed).

Remark : If you want to save this value automatically in the database, have a look at the extension “fhm_author”.

Page's author name

author.email

string

the email of the author (Atom feed). Beware: default Atom template does not write the email, you have to modify file templates/atom.php)

Remark : If you want to save this value automatically in the database, have a look at the extension “fhm_author”.

Page's author email

pidRootline

int

which page id define the first page of the Site (update on this page will be included too in the feed). It is useful with multi domain websites or to create feeds related to sections in the website

null

sysLanguageUid

int

which language (L parameter in multilingual sites) should be used to filter updated content. If left unconfigured, return all content in all languages

null

profileAjaxType

int

which page type should be used to include website content in the feed (useful to change the page type to use a stripped down layout – e.g., w/o menu – when reading the news in a newsreader such as Thunderbird)

0

ELEMENTS OF THE FEED CONFIGURATION (select.)

Property:

Data type:

Description:

Default:

title

string

the field of the database that corresponds to the "title" of an element in the feed. Most of the time, it will be tt_content.header

header

titleXPath

string

the field where the flexform is stored. Most of the time, it will be content.pi_flexform

pi_flexform

summary

string

the field of  the database that corresponds to the "body of an element in the feed. Most of the time, it will be tt_content.bodytext

bodytext

summaryXPath

string

the field of the database that corresponds to the "body of an element in the feed. Most of the time, it will be tt_content.bodytext

utf-8

published

string

the field of the database that corresponds to the time stamp when the element is published

tstamp

updated

string

the field of the database that corresponds to the time stamp when the element is updated

tstamp

uid

string

the uid field name of the database

uid

pid

string

the page id's field name of the database

pid

filterField

string

define which field will be used to filter elements. Will be transform in a SQL statement like field = value => list_type = some_plugin

null

filterInclude

comma separated string

define which value will be used to filter elements. Will be transform in a SQL statement like field = value => list_type = some_plugin

null

filterExclude

comma separated string

define which value will NOT be used. Will be transform in a SQL statement like  list_type  != some_plugin

table

string

which table contains the element of the feed

tt_content

debug

true/false

output the request in the RSS feed. Maybe useful to debug the request.

false

linkItem

true/false

make a link to the element. Not always the case since in can be a administrative feed informing that a new user is created for example

false

defaultText

string

should the element contain a default value. Useful for administrative feed.

null