PDA

View Full Version : RSS Display Boxes help



ciuchs
02-18-2009, 10:41 PM
1) Script Title:
RSS Display Boxes

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex18/rssdisplaybox/index.htm

3) Describe problem: I have placed the rss display box on my site but the box won't display the feed. it works with the defaut feeds that comes with it but when i put my own feeds in it won't display it. i am using wordpress to generate my feeds. i did manage to get it working with a .atom feed but i have to manually update it.

here is the main.php file

<?php
//Function for ouputting the body of each RSS item displayed (inside loop)- DynamicDrive.com

require('../simplepie/simplepie.inc'); //Specify path to simplepie.inc on your server (by default located inside "simplepie" directory)
$feed = new SimplePie();
$feed->cache_location('cache'); //Specify path to cache directory on your server relative to this file
$feed->handle_content_type();
require('outputbody.php'); //Path to custom "outputbody.php" file relative to this file

//Specify list of RSS URLs
$rsslist=array(
"centralbsu" => "http://centralbsu.com/blog/?feed=rss2",
"bsublog" => "www.centralbsu.com/rss.atom" //no trailing comma after last RSS URL!!
);

////Beginners don't need to configure past here. Edit outputbody.php to format the output of each RSS item's body ////////////////////

$rssid=$_GET['id'];
$rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("<b>Error:</b> Can't find requested RSS in list.");
$cachetime=isset($_GET["cachetime"])? (int)$_GET["cachetime"] : 30; //Get cachetime. Default to 30 if not specified
$feednumber=isset($_GET["limit"])? (int)$_GET["limit"] : ""; //Get number of items to fetch. If not specified (""), all is fetched.

$templatename=isset($_GET["template"])? $_GET["template"] : ""; //get name of template, which is used by if/else logic within function outputbody()
if ($templatename!="" && !preg_match("/^(\w|-)+$/i", $templatename)) //Template name can only contain alphanumeric characters, underscore or dash (-)
die ("<b>Error:</b> Template name can only consist of alphanumeric characters, underscore or dash");

$feed->cache_max_minutes($cachetime);
$feed->feed_url($rssurl);
$feed->init();
$max = $feed->get_item_quantity($feednumber);


function outputitems(){
global $feed, $feednumber, $templatename;
$max = $feed->get_item_quantity($feednumber);
for ($x = 0; $x < $max; $x++){
$item = $feed->get_item($x);
outputbody($item, $templatename); //call custom outputbody() function
}
}

?>

<?php
if ($feed->data){
outputitems();
}

?>




here is the link to the site the box is on
http://www.centralbsu.com

ddadmin
02-19-2009, 02:04 AM
Per the code on your HTML page, you're attempting to call the RSS feed with ID "cssdrive":


var cssdrivebox=new rssdisplaybox("cssdrive", "cssdriveid", "someclass")

Inside main.php. there doesn't seem to be a RSS feed with that ID, however. That's because attempting to call: http://www.centralbsu.com/rssbox/main.php?id=cssdrive returns an error. Make sure it's defined.

ciuchs
02-19-2009, 03:06 AM
Thanks a lot! I would have never been able to figure it out, even though it was sitting right in front of me.

CIuchs