Hello
How can I turn the below code into a shareable widget? javascript and iframe are a no go because they won't pass link juice when crawled.
demo URL - http://fantasyknuckleheads.com/mashed/feedframe160x468.php
<?php
require_once('../php/simplepie.inc');
$feed = new SimplePie();
$feed = new SimplePie('http://feeds.feedburner.com/fantasyknuckleheads/hTLk');
$feed->handle_content_type();
$feed->init();
//Get an image
function returnImage ($text) {
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
//echo $text;
$pattern = "/<img[^>]+\>/i";
preg_match($pattern, $text, $matches);
$text = $matches[0];
return $text;
}
////////////////////////////////////////////////////////////////
//Filter out image url only
function scrapeImage($text) {
$pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/';
preg_match($pattern, $text, $link);
$link = $link[1];
return $link;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style160x468.css" type="text/css" media="screen" charset="utf-8" />
<title>Fantasy Football</title>
</head>
<body>
<div id="container">
<ul id="widget">
<?php foreach($feed->get_items(0, 15) as $item) : ?>
<li>
<?php
$feedDescription = $item->get_content();
$image = returnImage($feedDescription);
$image = scrapeImage($image);
echo '<img title="fantasy football" style="background-image:url(http://fantasyknuckleheads.com/wp-content/uploads/2010/04/n.gif)" src="' .$image. '"/>';
?><p><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></p>
</li>
<?php endforeach; ?>
</ul>
</div><!--end container-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.newsScroll.js"></script>
<script type="text/javascript">
$('#widget').newsScroll({
speed: 2000,
delay: 5000
});
// or just call it like:
// $('#widget').newsScroll();
</script>
</body>
</html>
Any tips or tricks appreciated.
Kutu