WordPress.org

Ready to get started?Download WordPress

Forums

Winter Olympics Medal Count plugin? (12 posts)

  1. RyeBrye
    Member
    Posted 8 years ago #

    Anyone want to help me bang out a quick medal count plugin? I've been trying to find an XML feed of the medal count - but no such luck yet. Google has a medal count that shows up if you just type "olympics medal count" but that's not on my blog :P

  2. hbalagh
    Member
    Posted 8 years ago #

    that would be interesting i would love to have something on my blog like this too

  3. RyeBrye
    Member
    Posted 8 years ago #

    http://cbs.sportsline.com/olympics/box-scoreboards

    That's the cleanest source of data I've seen so far - just a plain table.

    The NBC olympics one loads the data in arrays so that you can sort it by different categories.

  4. Ming
    Member
    Posted 8 years ago #

    Yahoo! has RSS feeds for the medal count. Not sure how often the feed is updated.

    http://sports.yahoo.com/olympics/torino2006/medals

  5. RyeBrye
    Member
    Posted 8 years ago #

    That RSS feed is probably a good source. It still doesn't have the data in XML - the data is sent out in an HTML table. Not a bad start. I might play with this later today if I get time.

    What's the best way to snag data in PHP? Does it have good support for regular expressions, or am I going to have to write a script to troll through and manually parse it out of the table?

  6. hbalagh
    Member
    Posted 8 years ago #

    i think it would also be cool for when the world cup comes to have a similiar plugin

  7. RyeBrye
    Member
    Posted 8 years ago #

    I got something working using the CG FeedReader plugin, a little bit of CSS work - and that RSS feed you sent me.

    Here's the way you do it... First download and install the CG-PowerBack:

    http://www.chait.net/index.php?p=238/

    (The latest version for 1.5.13 works fine for WordPress 2.0) - install those plugins with the instructions given

    In your sidebar.php - add the following: (Replace "Title you want" with whatever titling method you use inside your sidebar. I use <h2> tags...)


    <div id="medalcount"> Title you want
    <?php
    $feedUrl = "http://sports.yahoo.com/olympics/torino2006/medals/rss.xml";

    $feedOut = getSomeFeed($feedUrl, $maxItemsPerFeed=1, $showDetails=true, $cacheName="feed-medalcount", $filterCat='',$tLimit = -1, $dLimit = -1, $noHTML = false,
    $showTime = true, $feedStyle = 0, $noTitle = true, $showTimeGMT = false, $titleImages = false, $multiSiteTitle=false,$makeRSS=false, $rssName="CG-FeedRead Multifeed", $rssLink="http://www.chait.net/");

    if ($feedOut)
    echo $feedOut;
    ?>
    </div>

    In your CSS file, if you want to get rid of the titles so it blends in better, include these lines:

    .medalcount .feedDescription {
    display: none;
    }

    .medalcount .feedItemTitle {
    margin: 0.5em 0 0 0;
    padding:0.5em;
    font-size:0.9em;
    }

    .medalcount .feedItem tr.last {
    display: none;
    }
    .medalcount .meta {
    font-size: 0.9em;
    padding: 0.5em;
    }

    That will get rid of the "Powered by Chevy Tahoe" line - along with the other lines, but will still link to Yahoo for the main medal count page.

    This solution works for me, so I'm not interested in building a custom plugin just for the next two weeks. When the worldcup comes along, just pray that Yahoo has an RSS feed for that medalcount, and this would be very simple to implement for that too (provided they throw a nice HMTL table in their RSS feed again)

    I haven't yet seen if the CG-FeedReader will automatically update the medalcount because I haven't seen Yahoo update it yet. I will know tomorrow if it actually updates the feed. :P

    You can see it working in my sidebar here:
    http://www.ryebrye.com/blog/

    You may have to expand the menu for it if it isn't expanded by default for you.

    Ryan

  8. Ming
    Member
    Posted 8 years ago #

    Nice work, I like it. I hadn't thought of checking medal counts through a RSS feed but now that you brought it up I'm surprised theres so little out there. It seems like a perfect use for syndication. Looks like you're just way ahead of the crowd!

  9. corruptinc
    Member
    Posted 8 years ago #

    Great Idea I have implemented on my page but I think the feed has changed today and a Graphic bar has been added for the medals. Not sure how to get rid of it as it is too wide for my sidebar.

    Any help is appreciated

  10. tylerc
    Member
    Posted 8 years ago #

    Thanks! I have it working at http://www.tylercranston.com

  11. RyeBrye
    Member
    Posted 8 years ago #

    Sorry I didn't monitor this thread better...

    To get rid of the graphic sidebar you need to make this change to the CSS... Unfortunately this means that the "G S B" text that used to be there is no longer - so the columns will have no identification.

    (It's simple enough for the average viewer to be able to decipher though... or at least it's easier to leave it headerless than it is to write some PHP to inject a header into it)

    .medalcount thead {
    display: none;
    }

    Edit: Another thing you will want to do when you implement this is make the CGFeedRead update your feed more often. This is done be editing the file:

    plugins/cg-plugins/cg-feedreed.php

    Edit line #50: Where it says
    $XML_CACHE_TIME = 6 * 60 * 60; // hr * min/h * secs/m -- you can change this for faster updates of the caches.

    (I think that was the default...)

    I changed mine to update every 10 minutes by using this code:

    $XML_CACHE_TIME = 1 * 10 * 60;

    If you ever want to manually reload the feed - simply delete the cache files in the cache_feedreed directory.

  12. corruptinc
    Member
    Posted 8 years ago #

    Thanks Appreciate it. This is terrific!

Topic Closed

This topic has been closed to new replies.

About this Topic