Tools_RSS

class Nos\Tools_RSS

Used to build a RSS feed.

Methods

::forge()

static Nos\Tools_RSS::forge($channel = array(), array $items = array())
Parameters:
  • $channel (mixed) – If it is a string, used as channel’s title. Associative array otherwise:
  • $items (array) – Associative array. Each key will be transformed into XML tag in a <item />.
Encoding :

Default UTF-8. Used for the XML encoding attribute.

Version :

Default 2.0. Used for XML version attribute (<rss> tag).

You can define any other key, which will be transformed into XML tag in the <channel />

Returns:

A instance of Tools_RSS.

::set()

Nos\Tools_RSS::set($property, $value = null)
Parameters:
  • $property (mixed) – A single string to set a channel property, or an associative array for multiple settings.
  • $value (mixed) – If $property is a string, the value of the property.

Set one or multiple channel properties.

::set_items()

Nos\Tools_RSS::set_items(array $items)
Parameters:
  • $items (array) – Array of items.

Set a new array of items.

::add_item()

Nos\Tools_RSS::add_item(array $item)
Parameters:
  • $item (array) – An item.

Add a new item to the $items array.

::build()

Nos\Tools_RSS::build(array $channel = array(), array $items = array())
Parameters:
  • $channel (mixed) –
  • $items (array) –
Returns:

The XML description of the RSS

See Tools_RSS::forge for parameters.

The pubDate key can be a Fuel\\Core\\Date instance, or a string (date representation) or a timestamp.

Examples

<?php
$rss = \Nos\Tools_RSS::forge('RSS title');
$rss->set_items(array(
        'title' => 'Item title',
        'link' => 'http://www.mydomain.com/item_url.html',
        'description' => '<p>A description of item </p>',
        'pubDate' => '2012-08-16',
        'author' => 'Me',
));
$xml = $rss->build();

$rss->set('subtitle', 'A subtitle for ma RSS');
echo $rss; // Call $rss->build() with magic method __ toString()
Read the Docs v: 0.2
Versions
latest
chiba.2
chiba.1
0.2
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.