
December 1st, 2012, 11:14 PM
|
 |
Contributing User
|
|
|
|
I created a widget based on this same idea; not to long ago. Though..., I didn't have the scroll up and down feature, but I did get the content from another site's XML feed and created my own JsPhp Widget. So... that's what I suggest for you too.
My JsPhp Widget Example
PHP Code:
scrapperJS.php
<?php
header("Content-type:text/javascript");
// Define PHP Variables
$widget_text = file_get_contents("https://cio.gov/category/blogs/feed/"); // Example of Word Press Blog XML Feed
$widget_text = addslashes($widget_text);
$widgeTextFormat = preg_replace("/\n/","",$widget_text);
// Define External JavaScript File
echo "var widgeText = \"$widgeTextFormat\";
var amount_of_listings = 10; // Define Amount of Blog Post To Display
function getWP()
{
amount_of_listings = amount_of_listings + 1;
document.getElementById(\"myWidget\").innerHTML=\"<hr/>\";
for (i=2;i<=amount_of_listings;i++) {
document.getElementById(\"myWidget\").innerHTML += \"<a href='\" + widgeText.split(\"<link>\")[i].split(\"</link>\")[0] + \"'>\" + widgeText.split(\"<title>\")[i].split(\"</title>\")[0] + \"</a><hr/>\";
}
}
document.onreadystatechange = function() {
if (document.readyState==\"complete\") {
new getWP();
}
}";
?>
Code:
HTML
<script type="text/javascript" src="scrapperJS.php"></script>
<span id="myWidget"></span>
|