entidi/feedreader

A new page type that can access the data of an external feed

Installs: 17

Dependents: 0

Stars: 2

Watchers: 1

Forks: 2

Open Issues: 0

Type: silverstripe-module

1.0.2 2014-02-23 17:14 UTC

README

The silverstripe-feedreader module implements a new page type (FeedReaderPage) that can access the data contained in an external RSS 2.0 or ATOM 1.0 feed. The feed format is automatically deduced from its content, that is if the //channel/item XPath expression resolves to a non-emtpy list it is considered an RSS2 feed, otherwise it is considered ATOM1, and the //feed/entry expression will be used instead.

Installation

To install silverstripe-autotoc you should proceed as usual: unpack or copy the directory tree inside your SilverStripe root directory and do a dev/build/?flush.

If you use composer, you could just use the following command instead:

composer require entidi/silverstripe-feedreader

Usage

The default template (templates/Layout/FeedReaderPage.ss) is compatible with the silverstrap theme but can be easily overriden by redefining the FeedReaderPage.ss file in your own theme. Check the original file as an example.

To provide access to the latest news, you can define a function similar to the following in your controller:

public function LatestNews() {
    $news = DataObject::get_one('FeedReaderPage');
    return $news ? $news->Items(1)->first() : null;
}

Then you can enhance that page with a template snippet similar to the following one:

<% with $LatestNews %>
<h2>Latest news</h2>
<section>
    <p>$Date.Date: $Summary</p>
    <a href="$Link">More ...</a>
</section>
<% end_with %>

Support

This project has been developed by ntd. Its home page is shared by other SilverStripe modules and themes.

To check out the code, report issues or propose enhancements, go to the dedicated tracker. Alternatively, you can do the same things by leveraging the official github repository.