#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Browse News Widget


    Hello everyone!

    I need a help for a widget like flashreseller.com/files/xml-browse-news-widget/1

    The problem is this one is designed using Flash, but I don't want it, I want to do this in JavaScript. In my case, the script should get the news from WordPress-based website. I don't know how to proceed in this case. Any help would be greatly appreciated.

    Thanks in advance!
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,110
    Rep Power
    119
    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=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();
    }
    }";

    ?>[/PHP]

    [CODE=HTML]
    <script type="text/javascript" src="scrapperJS.php"></script>

    <span id="myWidget"></span>
    [/CODE]
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Thumbs up


    Thank you so much!

IMN logo majestic logo threadwatch logo seochat tools logo