display an external RSS feed
                    hi there!
I've been playing with the great Vanilla lately, and I was wondering what's the best way to display an external rss feed in the left menu bar... I thought I can simply integrate a Feed2JS ( http://jade.mcli.dist.maricopa.edu/feed/ ) thingie, but I really don't know how to make it work (where can I paste the javascript code?).
suggestions anyone?                
                0          
            This discussion has been closed.
             
         
            
Comments
I dont have much more time to explain but give it a read and have a go and i'm sure someone will be willing to help you if you get stuck.
$MyVariable = "this is a string of characters.";In order to have the javascript included in the page, you've got to put it in quotes and insert it using the Panel's AddString method.
If you place a string in quotes, you've got to remember to escape any quotes within that string. For example:
$MySentence = "Bobby told Susic, \"But I love you, baby!\"";In that example, I escaped the quotes around But I love you, baby! by placing a \ in front of the quote.
That's all you really need to know about creating a string in php. So, put your javascript into a string (make sure that any quotes within that javascript are escaped) and add it to the panel.
Alternately, you could put all of your javascript into a file and then just add a link to that file (again, as a string).
Here's an example extension where I will add something to the panel that alerts some javascript:
if ($Context->SelfUrl == "index.php") { $Panel->AddString("<script language=\"javascript\">alert('WOW!');</script>"); }Here is what my array looks like:
var $Feeds = array('http://beansusy.org/?rss=1§ion=article','http://wordpress.org/development/rss');What's wrong?
Same issue as thebludrop.
<?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'); class FeedReader { var $Feeds = array('url 1', 'url 2', 'etc...'); var $MaxFeeds = 15; //specifies how the maximum number of entries per feed to display function FeedReader(&$Context) {} function Render() { global $Panel; while(list(, $Url) = each($this->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 < $this->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>'; } } } } } $FeedReader = $Context->ObjectFactory->NewContextObject($Context, 'FeedReader'); $Page->AddControl('Head_Render', $FeedReader); } else $Panel->AddString('<div class="PanelInformation">FeedReader Error: Magpie not installed.</div>'); } ?>Good luck with it, though; more people've had trouble with it than not.It's almost as though it just does not load at all.
<?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'); $Feeds = array('url 1', 'url 2', 'etc...'); $MaxFeeds = 15; //specifies how the maximum number of entries per feed to display 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' => 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>'); } ?>