Quick links: Content - sections - sub sections

jResponseRss20 allows to generate an RSS feed. It's fully compliant with RSS 2.0 specifications.

The alias usable with getResponse is "rss2.0":

  $resp = $this->getResponse('rss2.0');

RSS Feed Informations

jReponseRss20's property infos is an object allowing to set the RSS feed's properties: title, website url, copyright, description, etc.

For example:

   $resp->infos->title = 'Jelix news';
   $resp->infos->webSiteUrl= 'http://jelix.org/';
   $resp->infos->copyright = 'Copyright 2006-2008 jelix.org';
   $resp->infos->description = 'News about Jelix, fresh meat for hairy trolls.';
   $resp->infos->updated = '2007-06-08 12:00:00';
   $resp->infos->published = '2007-06-08 12:00:00';
   $resp->infos->ttl = 60;

Property ttl is the cache-timeout, in minutes. Property description should be a string; however it's possible to specify the format (HTML or XHTML) in property descriptionType. Property descriptionType expects any of the following values : "html", "xhtml" ou "text".


The RSS channel should be fed with items to publish. For example, items can have the description of each new tickets of a blog.

Each item should be created with jResponseRss20's method: createItem(). It allows to fetch an object with item's informations. You can fill this object and add it the the response with jResponseRss20's method : addItem().

For example, with a news DAO:

  $newsdao = jDao::get('news');
  $first = true;

  Fetch the ten last news from the DAO,
  assuming it's ordered from the newest to the oldest.
  (method defined in the DAO)
  $list = $newsdao->findTenFirstNews();

  foreach($list as $news){

        The first record allow to fetch channel's date
        $resp->infos->updated = $news->date_create;
        $resp->infos->published = $news->date_create;
        $first = false;

    // Fetch the URL from the news article
    $url = jUrl::get('news~default:article', array('newsid'=>$news->id));

    // Create an RSS item, specifying the title, url, and date (format : [yyyy-mm-jj hh-mm-ss] )
    $item = $rep->createItem($news->title, $url, $news->date_create);

    // News author
    $item->authorName = $news->author;

    // Item's contents
    $item->content = $news->content;
    $item->contentType ='html';

    Assuming the news-URL being the news-ID in this example.
    Note that it would have been possible to use : $item->id =$news->id
    $item->idIsPermalink = true;

    // Add this item to the feed.

Other informations

It's possible to explicitely specify more informations about the RSS food or about each item.

Check the API documentation about jRSS20Info and jRSSItem to go deeper.