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

edited March 2006 in Vanilla 1.0 Help
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?
«1

Comments

  • edited November 2005
    If you check out the documentation for 'adding controls to the control panel' under 'developing extensions' it should give you a reasonable idea how to get stuff in there - try with text first and then if it works swop in the js and cross your fingers.
    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.
  • I tried your solution, but apparently php extension files don't like js too much...
  • It shouldn't if you put it in a string and handled it correctly.
  • sorry I'm a php n00b and I don't even know what a string exactly is...
  • MarkMark Vanilla Staff
    edited November 2005
    What I'm writing right now is a string. A string of characters.

    $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>");
    }
  • NickENickE New
    edited November 2005
    Here, this'll probably be easier and actually use fewer resources. Instead of Feed2Js, install MagpieRSS (the same engine used by Feed2Js) in Vanilla's root directory with the folder name of 'magpie', then enable this extension. Admittedly, there's no administration panel, but tweaking things in the extension file should be very easy.
  • edited November 2005
    thanks a lot for these explanations mark an SirNot , I might be able to make this work now, in a way or an other.
  • So I've succesfully integrated the feed using mark's technique, for an obscure reason the FeedReader extension wasn't working at all (I followed your instructions SirNot, and even CHMODed the magpie directory to 777 just in case, but no luck, nothing was displayed at all...) anyway, thanks again folks!
  • NickENickE New
    edited November 2005
    Hmm, that's odd; worked for me. Even if magpie isn't installed, the extension should give you a warning on the side bar about it. You did install the extension and changed the Feeds array strings, right? Oh, I see what might be wrong. While the extension alerts you both if magpie is not installed and if it cannot connect to the feed, it won't tell you anything if there isn't anything in the feed. In other words, 4* errors, simply no news, etc. Try double checking your url and the actual source to see if they're correct and actually display something on a normal RSS feed.
  • Thanks a lot SirNot! Your extension works perfect and a nobrainer to install - Jens
  • I can't get this extension to work either. I installed it and I installed magpie and I am not getting any errors anymore, I am only getting nothing.

    Here is what my array looks like:
    var $Feeds = array('http://beansusy.org/?rss=1&section=article','http://wordpress.org/development/rss');

    What's wrong?
  • Just for the record, I could not get this extension to work either.

    Same issue as thebludrop.
  • I am just not having any luck with extensions at the moment, am I? Try it now, it should at least say something. If it dosn't, then somehow it's not even being executed properly.
  • I think it's not being executed properly. I am not seeing anything show up in the "sidebar" on the discussions page.
  • same here, I'm also not able to get this extention to work.
  • Same problem here :\
  • Does someone have a copy of FeedReader.php.txt? Would be nice if it can be put online again :)
  • NickENickE New
    edited February 2006
    Think this is the right version...
    <?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.
  • Does this require a version other than 0.9.2.6? I seem to be having the problems of those above but no error messages nothing.

    It's almost as though it just does not load at all.
  • Try this, and see if it works (haven't even tested it yet, so it could pop up with a parse error for all I know...):
    <?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>');
    }
    
    ?>
This discussion has been closed.