Documentation
RSS view
Table of Contents ▼
Presentation
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).
Usage
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'] = 'https://mysite.com';
$this['title'] = 'My super site';
$this['description'] = 'Blah blah blah blah blah';
$this['language'] = 'en';
$this['contact'] = 'contact@mysite.com';
$this['articles'] = [
[
'title' => 'Happy new year!',
'url' => 'https://mysite.com/page/23',
'pubDate' => '2000-01-01 00:00:00',
],
[
'title' => 'New decade',
'url' => 'https://mysite.com/page/734',
'pubDate' => '2010-01-01 00:00:00',
],
];
// set the used view
$this->_view('\Temma\Views\Rss');
}
}
- 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">
<channel>
<link>https://mysite.com</link>
<title>My super site</title>
<description>Blah blah blah blah blah</description>
<language>en</language>
<managingEditor>contact@mysite.com</managingEditor>
<webMaster>contact@mysite.com</webMaster>
<generator>Temma RSS generator 1.0.0</generator>
<category>Blog</category>
<item>
<title>Happy new year!</title>
<link>https://mysite.com/page/23</link>
<pubDate>Sat, 01 Jan 2000 00:00:00 +0100</pubDate>
</item>
<item>
<title>New decade</title>
<link>https://mysite.com/page/734</link>
<pubDate>Fri, 01 Jan 2010 00:00:00 +0100</pubDate>
</item>
</channel>
</rss>
Previous: | CSV view |
Next: | INI view |
Table of Contents
- Migration : How to upgrade from Temma 1.x to version 2
- Installation : Download Temma and install it to start your web project
- Configuration : All the configuration directives of the etc/temma.json file and the optional environment variables
- External libraries : How to use external function libraries
- Routing : Temma's default routing system, and advanced routing
- Log : Use of the log system, management by criticality levels
- Controllers : Essential parts of your web application
- Views : Smarty templates or JSON/CSV/RSS/iCal/INI exports
- Dependency injection : The backbone of your application developments
- Sessions : Extension of user sessions managed by PHP
- Data sources : Unified data access management
- Model : How to use DAOs to access databases
- Execution flow : How to manage the execution flow, between plugins and the controller
- Plugins : How to use plugins, and create your own plugins to modularize your code
- Attributes : How to filter access to controllers and actions
- Tests : To write automated integration tests.
- Command-line interface : To create executable scripts on the command line, automatically initialized by Temma
- Helpers : Items offered by Temma to help you in various circumstances