The dmWidgetFeedReaderPlugin
allows to load and display feeds on your site.
It packages a Diem front widget to show feed items from a url.
git clone git://github.com/ornicar/dmWidgetFeedReaderPlugin.git plugins/dmWidgetFeedReaderPlugin
class ProjectConfiguration extends dmProjectConfiguration { public function setup() { parent::setup(); $this->enablePlugins(array( // your enabled plugins 'dmWidgetFeedReaderPlugin' ));
php symfony dm:setup
This widget loads a feed from a url, and displays feed items.
To use it, just drag&drop a Feed Reader/Show widget somewhere on your site.
Configure the widget on the widget edition dialog:
- url Feed url to load.
- nb_items Number of feed items to display.
- life_time Duration of the cache in seconds.
Copy
plugins/dmWidgetFeedReaderPlugin/modules/dmWidget/templates/_dmWidgetFeedReaderShow.php
to
apps/front/modules/dmWidget/templates/_dmWidgetFeedReaderShow.php
then modify it.
Default template:
/* * An $item is an array containing: * - title: title of the feed item * - link: url of the feed item * - content: HTML content * - pub_date: item publication date (timestamp) * - author_name: author name * - author_link: author link * - author_email: author email */ echo _open('ul'); foreach($items as $item) { echo _tag('li', // link to the feed page _link($item['link'])->text($item['title'])->set('.feed_item_link'). // render truncated feed content _tag('div.feed_item_content', dmString::truncate(strip_tags($item['content']), 100)) ); } echo _close('ul');
This template uses Diem template helpers
You can modify the list of feed items before they are displayed by listening the dm.widget_twitter_feed_reader_show.items event.
apps/front/frontConfiguration.class.php
class frontConfiguration extends dmFrontApplicationConfiguration { public function configure() { // connect to the dm.widget_feed_reader_show.items event $this->dispatcher->connect('dm.widget_feed_reader_show.items', array($this, 'listenToFeedReaderShowItemsEvent')); } public function listenToFeedReaderShowItemsEvent(sfEvent $e, array $items) { // do something with the feed items ... // return the filtered items return $items; }
dmWidgetFeedReaderPlugin, created on January 22, 2010 by Thibault D, used by 2721 projects