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

2»

Comments

  • Hey thanks! That seems to have done the trick. I think I'm checking it only wih the RSS from this board so all I see is "dispaly an external RSS feed" multiple times.
  • Just tested it with another and it works! Excellent!
  • Hmm, so the majority of my troubles seem to rest in hooking into the head render control...
  • edited February 2006
    Could that be the same for this one as well Page Management
  • ithcyithcy New
    edited February 2006
    this extension works great in 0.9.3. in fact i hacked it up a little, so that users can display custom feeds in addition to some (or no) "global" ones set by administrator.

    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:[email protected] 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:[email protected] */ 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>'); } ?>
  • well i thought it was cool.
  • Interesting and a nice enhancement, but since I just got the original working I don't think I want to mess with it right now :-)
  • I modified your code to match with what SirNot updated for me, also named it differently so I could have both "Feed" and "User Feeds"

    <?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>'); } ?>
  • interesting. what's the difference between the version SirNot just posted up there and "what SirNot updated for you" ?
  • "Hmm, so the majority of my troubles seem to rest in hooking into the head render control..."

    Only slight modifications it seems.
  • Although I must admit I've yet to see a major difference - haven't done a "compare" of the two files though.

    His works for me and yours not though.
This discussion has been closed.