RSS view


The RSS view allows you to send feeds in RSS format, used in particular to list the content posted on a content site (such as a blog).


To use the RSS view, you must define the use of this view. In addition to that, you must assign several template variables:

  • title: (mandatory) Defines the title of the site.
  • description: (mandatory) Defines the description of the site.
  • domain: (mandatory) Defines the domain name of the site.
  • language: (optional) Defines the language of the site (or the language of the conteus listed in the RSS feed).
  • contact: (optional) Defines the contact email address of the site.
  • copyright: (optional) Copyright information.
  • category: (optional) Category of the site. Blog by default.
  • articles: Defines the list of articles to be listed in the feed. Each element of the list must be an associative array with the following keys:
    • title: (mandatory) Title of the article.
    • url: (mandatory) URL of the article.
    • pubDate: (optional) Publication date in 'YYYY-MM-DD hh:mm:ss' format.
    • abstract: (optional) Summary of the article.
    • author: (optional) Email address of the author.
    • guid: (optional) Unique identifier of the article (use its URL otherwise).

Here is an example of sending data in RSS format:

class ApiController extends \Temma\Web\Controller {
    public function getArticles() {
        $this['domain'] = '';
        $this['title'] = 'My super site';
        $this['description'] = 'Blah blah blah blah blah';
        $this['language'] = 'en';
        $this['contact'] = '';
        $this['articles'] = [
                'title'    => 'Happy new year!',
                'url'      => '',
                'pubDate'  => '2000-01-01 00:00:00',
                'title'    => 'New decade',
                'url'      => '',
                'pubDate'  => '2010-01-01 00:00:00',

        // set the used view
  • Lines 3 to 21: Definition of the data that will be transmitted to the view.
  • Line 24: We specify that the view to use for the outgoing data is the RSS view (and not the usual Smarty view).

Note: The RSS view obviously does not need templates, since it is the PHP data that is directly serialized.

The received data will look like this:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <title>My super site</title>
    <description>Blah blah blah blah blah</description>
    <generator>Temma RSS generator 1.0.0</generator>
        <title>Happy new year!</title>
        <pubDate>Sat, 01 Jan 2000 00:00:00 +0100</pubDate>
        <title>New decade</title>
        <pubDate>Fri, 01 Jan 2010 00:00:00 +0100</pubDate>


If you want the RSS feed to be sent as a downloadable attachment, define a template variable named filename, containing the file name.


$this['filename'] = 'january.rss';