Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
display an external RSS feed
This discussion has been closed.
Comments
this works through your (the user's) Account->Personal Information page.
to add a new rss feed, click the "add another label/value pair" link at the bottom, and in the first box put "rss_feed", and in the second box paste the rss link.
if you want to get rid of one of the feeds you have, just clear the relevant boxes and hit Save.
to change how many headlines appear for each feed, add another label/value pair. in the left box put "max_feeds" and in the right box put a number - however many headlines you want per feed. (the global maximum of # feeds and # headlines per feed is set by the administrator, in the code below.)
vanilla expert hackers, if i'm going about this the wrong way, please enlighten me.
<?php /* Extension Name: Feed Reader Extension Url: mailto:sirnot@gmail.com Description: Adds a little something to the side panel which displays feeds from a certain source. MagpieRSS must be installed under the directory name of 'magpie' in Vanilla's root folder. Version: 1.0 Author: SirNot Author Url: mailto:sirnot@gmail.com */ if(@$Panel) { if(file_exists('magpie/rss_fetch.inc')) { require_once('magpie/rss_fetch.inc'); $FeedsLimit = 5; // how many custom feeds, maximum, that users are allowed $FeedHeadlinesLimit = 10; // how many headlines per custom feed, maximum, that users are allowed $MaxFeeds = $DefaultMaxFeeds = 5; if (!@$UserManager) $UserManager = $Context->ObjectFactory->NewContextObject($Context, "UserManager"); $AccountUserID = ForceIncomingInt("u", $Context->Session->UserID); if (!@$AccountUser) $AccountUser = $UserManager->GetUserById($AccountUserID); $Feeds = array(); // if you want to force some feeds on everyone (in addition to their custom feeds) // then comment out the above line $Feeds = array() and uncomment the below line // $Feeds = array('http://feed.everyone.must.see','http://another.feed.everyone.must.see','...') foreach($AccountUser->Attributes as $attr) { if ($attr['Label'] == 'rss_feed' && count($Feeds) < $FeedsLimit) { array_push($Feeds, $attr['Value']); } elseif ($attr['Label'] == 'max_feeds') { $MaxFeeds = $attr['Value']; } $MaxFeeds = ($MaxFeeds > $FeedHeadlinesLimit) ? $FeedHeadlinesLimit : $MaxFeeds; } while(list(, $Url) = each($Feeds)) { $Rss = @fetch_rss($Url); if(!$Rss) { $Panel->PanelElements[] = array('Type' => 'String', 'Key' => count($Panel->Strings)); $Panel->Strings[] = '<div class="PanelInformation">Feed failed to load<br />URL: '.$Url.'</div>'; } else { $RssCount = count($Rss->items); if($RssCount) { $Title = 'Feed: '.FormatStringForDisplay($Rss->channel['title']); $Panel->PanelElements[] = array('Type' => 'List', 'Key' => $Title); $Panel->Lists[$Title] = array(); for($i = 0; $i < $RssCount && $i < $MaxFeeds; $i++) { $Panel->Lists[$Title][] = array( 'Item' => mb_convert_encoding($Rss->items[$i]['title'],'HTML-ENTITIES'), 'Link' => FormatStringForDisplay($Rss->items[$i]['link']), 'Suffix' => '', 'LinkAttributes' => 'target="x"' ); } } else { $Panel->PanelElements[] = array('Type' => 'String', 'Key' => count($Panel->Strings)); $Panel->Strings[] = '<div class="PanelInformation">No information in feed<br />URL: '.$Url.'</div>'; } } } } else $Panel->AddString('<div class="PanelInformation">FeedReader Error: Magpie not installed.</div>'); } ?>
<?php /* Extension Name: User Feed Reader Extension Url: http://lussumo.com/community/discussion/1139/display-an-external-rss-feed/ Description: Adds a little something to the side panel which displays feeds from a certain source. MagpieRSS must be installed under the directory name of 'magpie' in Vanilla's root folder. Version: 1.0 Author: SirNot / itchy Author Url: http://lussumo.com/community/account/87/ */ if(@$Panel) { if(file_exists('magpie/rss_fetch.inc')) { require_once('magpie/rss_fetch.inc'); $FeedsLimit = 5; // how many custom feeds, maximum, that users are allowed $FeedHeadlinesLimit = 5; // how many headlines per custom feed, maximum, that users are allowed $MaxFeeds = $DefaultMaxFeeds = 5; if (!@$UserManager) $UserManager = $Context->ObjectFactory->NewContextObject($Context, "UserManager"); $AccountUserID = ForceIncomingInt("u", $Context->Session->UserID); if (!@$AccountUser) $AccountUser = $UserManager->GetUserById($AccountUserID); $Feeds = array(); // if you want to force some feeds on everyone (in addition to their custom feeds) // then comment out the above line $Feeds = array() and uncomment the below line // $Feeds = array('http://feed.everyone.must.see','http://another.feed.everyone.must.see','...') foreach($AccountUser->Attributes as $attr) { if ($attr['Label'] == 'rss_feed' && count($Feeds) < $FeedsLimit) { array_push($Feeds, $attr['Value']); } elseif ($attr['Label'] == 'max_feeds') { $MaxFeeds = $attr['Value']; } $MaxFeeds = ($MaxFeeds > $FeedHeadlinesLimit) ? $FeedHeadlinesLimit : $MaxFeeds; } while(list(, $Url) = each($Feeds)) { $Rss = @fetch_rss($Url); if(!$Rss) { $Panel->PanelElements[] = array('Type' => 'String', 'Key' => count($Panel->Strings)); $Panel->Strings[] = '<div class="PanelInformation">Feed failed to load<br>URL: '.$Url.'</div>'; } else { $RssCount = count($Rss->items); if($RssCount) { $Title = 'User Feeds: '.FormatStringForDisplay($Rss->channel['title']); $Panel->PanelElements[] = array('Type' => 'List', 'Key' => $Title); $Panel->Lists[$Title] = array(); for($i = 0; $i < $RssCount && $i < $MaxFeeds; $i++) { $Panel->Lists[$Title][] = array( 'Item' => FormatStringForDisplay($Rss->items[$i]['title']), 'Link' => FormatStringForDisplay($Rss->items[$i]['link']), 'Suffix' => '', 'LinkAttributes' => '' ); } } else { $Panel->PanelElements[] = array('Type' => 'String', 'Key' => count($Panel->Strings)); $Panel->Strings[] = '<div class="PanelInformation">No information in feed<br>URL: '.$Url.'</div>'; } } } } else $Panel->AddString('<div class="PanelInformation">FeedReader Error: Magpie not installed.</div>'); } ?>
Only slight modifications it seems.
His works for me and yours not though.