Diem plugins syndication

dmWidgetFeedReaderPlugin

Displays RSS and Atom feeds on your site

The dmWidgetFeedReaderPlugin allows to load and display feeds on your site.
It packages a Diem front widget to show feed items from a url.

Installation

  • In a console, from your project root dir, run:
git clone git://github.com/ornicar/dmWidgetFeedReaderPlugin.git plugins/dmWidgetFeedReaderPlugin  
  • In config/ProjectConfiguration.class.php, add dmWidgetFeedReaderPlugin to the list of enabled plugins:
class ProjectConfiguration extends dmProjectConfiguration
{  
  public function setup()  
  {  
    parent::setup();  
 
    $this->enablePlugins(array(  
      // your enabled plugins  
      'dmWidgetFeedReaderPlugin'  
    ));  
  • In a console, from your project root dir, run:
php symfony dm:setup  

Feed Reader Show widget

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.

Options

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.

Customize the template

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

Filter items with an event

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;  
  }  

    Add a comment

    Create an issue
    Impossible to fetch issues for this plugin.
    Impossible to get this plugin changelog.
    See more commits

    dmWidgetFeedReaderPlugin, created on January 22, 2010 by Thibault D, used by 2721 projects

    Fork Diem on GitHub