The view from here
11 Apr
For a while, I have been using PopURLs as a quick and dirty way of scanning interesting websites for what’s new. It is not a RSS reader substitute, but if I have a couple of minutes and just want to see something new, it’s a good spot to stop. A few weeks ago, with a few free cycles, I wondered just how difficult it would be to roll my own. Nothing as pretty, but something that would give me some exposure to what’s under the covers.>
A couple of days ago, buzz started to build around Alltop which was built by Guy Kawasaki’s Nononina, also behind the site Truemors. Alltop is a very pretty site with a wide variety of content, but it too is based on the same content (and looking at the page sources, potentially the same code base).
If you want to build your own, I offer you my findings, code and lessons learned
Technorati Tags: php, popurls, alltop
As this is a quick and dirty implementation, I apologize if the code base contains some minor bad practices. In most cases, I’ve adhered to standards that should allow you to unzip and deploy, but if something doesn’t quite work, take a look at the code. It was intended to be deployed on the URL news.delic.com so take a look for any part of that string if paths don’t work.
Please leave all of the GPL, BSD, CC and other licenses in the code intact, if you publish this. Any changes I have made to the code are extensions of these licenses. You are free to reuse any code I have written, but if there’s a license embedded in there, you should leave it there.
News aggregation source code (zip format, 490Kb)
If you are interested in rolling your own version of the aggregator, I have listed the components below, along with links to some of the relevant installation instructions and documentation
If you are hosted on Dreamhost and running PHP 5+, you will have all of the minimum and recommended components listed above available to you via the php5 default install.
<?php echo newsblocks::render (’http://digg.com/rss/index.xml’); ?>
The SimplePie Documentation has all of the options one might need to increase the number of articles pulled from the feed, the cache periods, etc.
To get Cluetip to work, there are two necessary steps:
<script type=”text/javascript”>
jQuery.noConflict();
// Put all your code in your document ready area
jQuery(document).ready(function($){
// Do jQuery stuff using $
$(”a.ctip”).cluetip({
splitTitle: ‘|’, // use the invoking element’s title attribute to populate the clueTip…
// …and split the contents into separate divs where there is a “|”
showTitle: false // hide the clueTip’s heading
});
});
</script>
$html .= ‘<li class=”‘ . $class . ‘”><a href=”‘ . $item->get_permalink() . ‘” title=”‘ . newsblocks::cleanup ($item->get_description(), $length) . ‘”>’ . $item->get_title() . ‘</a> </li>’ . “\n”;
and change it to:
$html .= ‘<li class=”‘ . $class . ‘”><a class=”ctip” href=”‘ . $item->get_permalink() . ‘” title=”|’ . newsblocks::cleanup ($item->get_description(), $length) . ‘”>’ . $item->get_title() . ‘</a> </li>’ . “\n”;
* = Alltop and PopURLs are registered trademarks and/or servicemarks of Nononina and Thomas Marban respectively. This site is not affiliated with them in any way.
57 Responses for "Building your own Alltop or PopURLs*"
This is a fantastic tutorial! I’ve added it to our tutorials page: http://simplepie.org/wiki/tutorial/start . If you write any more tutorials for SimplePie, feel free to add them yourself.
ive been having problems with my website. I used also the simplepie tutorial but i have a problem with the tooltip. It is working in my localhost but when i upload it to my server is not working. What do you think is the problem?
Thank you very much
Can you give me a URL? There’s not a lot of detail to go on in your post - if I can see more, I might be able to diagnose
Thanks a million for this code. It was exactly what I’ve been looking for.
I’m having a bit of a problem with the spacing at the top of the page between the header and the news feeds. I would like to mostly eliminate it, but I’m not sure how. I was able to get rid of 30px of it from .clearer, but there’s still 50-60px that I can’t figure out where it’s coming from. I’ve added an image to mine but the gap appears either way.
Thanks again,
Mike
resolved Mike’s issue - he needed to remove the div with the id of “header”
Question - is there an easy way to pull the first image url out? Or perhaps an easy way to pull / render an ebay feed ?
Thanks
@ patrick
tags.
yes. look in the newsblock.inc file for the render_flickr function. This will look at the item description and pull out the
If your description has multiple
tags in it, replace the code:
foreach ($matches[0] as $match)
{
// Add the images (only) back to $s.
$s .= $match;
}
with:
//Take only the first image match and be done with it
$s = $matches[0][0];
(replace the entire foreach loop with the above statement.
I’ve also been busy with simplepie newsblock and created a celebrity url hyve.
http://www.richyshameless.com
Still busy working on it checking new feeds etc.
In addition to my post above.
Do any of you know how to center align the contente of the wideblock? (the video thumbnails) They are always aligned to the left and i can’t figure out how to center them.
There’s no immediate way to do this, but you could adjust the padding on the wideblock class. Since the entire container is 950px wide, and you know the size of the thumbnails and number of thumbnails per row, you could do some quick math to figure out the appropriate padding
Hi,
Great tutorial! I really appreciate it…
I’ve downloaded your example-package, and uploaded it to my FTP ( http://www.marcfalk.com/ag/ ) , but the javascript doesn’t seem to work, how come? any idea..?
Help is appreciated! Thanks in advance…
Marc
Hmm. It appears that the zipfile doesn’t include the scriptaculous subdir in the js/ sub-dir. I reupped the zip file. If you uncompress it, it will unzip into a directory called “news.delic.com”. You can move the contents to the right place, or just the news.delic.com/js/scriptaculous/ directory into your js directory.
Let’s see if that works
Raj
Hey, thanks for the answer! But I’m sorry to say it didn’t work out as expected. I actually think the scriptaculous dir was already in place, but I upped the new zip anyway, and it still looks like this: http://www.marcfalk.com/ag/ or http://www.houseofsaints.dk/ag/
Hmm.. It doesn’t make any sense! :/
Marc
Oh, I red this (http://tech.groups.yahoo.com/group/simplepie-support/message/1130) and it helped me. It seems like you have to remove the .htaccess-file, now it works.
What did that .htaccess do? Do I need it?
Marc
The .htaccess file is used to tell the webserver who should have access to the directory and what they can do (for example, anonymous users can’t read the directory listing, or you need to supply a username and password to access a file).
I think the .htaccess file came from your webserver (I can’t find one in my zip file, if anyone does find one, let me know).
Not having it there isn’t really an issue, but don’t put anything you don’t want the world to be able to see into this set of directories
Raj
how do i change the background and text color of boxover? Where can i edit the mouse over effect?
everything else is great.
Thank you.
I just uploaded the whole folder to my server and it worked!!
It-s that easy ??
Thank you.
Thinking it would be easy I uploaded the whole folder to my server but it didn’t work. I’m getting:
Warning: ./cache/43d45d4504fae280ade72bf910736904.spc is not writeable in /php/includes/simplepie.inc on line 1769
Warning: cannot yet handle MBCS in html_entity_decode()! in /php/includes/newsblocks.inc on line 744
Warning: cannot yet handle MBCS in html_entity_decode()! in /php/includes/newsblocks.inc on line 744
Warning: cannot yet handle MBCS in html_entity_decode()! in /php/includes/newsblocks.inc on line 744
Warning: cannot yet handle MBCS in html_entity_decode()! in php/includes/newsblocks.inc on line 744
Warning: cannot yet handle MBCS in html_entity_decode()! in php/includes/newsblocks.inc on line 744
Warning: cannot yet handle MBCS in html_entity_decode()! in php/includes/newsblocks.inc on line 744
can anyone help?
I believe your cache directory does not have the right permissions.
see: http://simplepie.org/wiki/setup/setup#step_3
Great stuff! I have only one question, how can you either remove the “more” link at the bottom of feeds (I noticed the newsblock has this whole 2nd div for it but no one has it working) or actually put it to use? Thanks in advance!
Since i am having a big problem with tooltips here at my news aggregator site ( http://malayapark.com). I think this is a very good option for me. Thanx for the sharing
wonderful… thanks for sharing
Any chance of there being a plugin for WordPress 2.6′ish? Being able to create special pages with feeds specific to each page would be helpful. Feel free to email if you have suggestions. I’ll Digg and Stumble this to assist with me remembering the domain.
Thanks
macewan
Hey, thanks much for sharing this. Quick question for you….I’m getting the following error message:
“A feed could not be found at http://rss.tailrank.com/posts“
Yet that tailrank.com feed does show up! Is this just a problem with that particular feed for some reason? It isn’t a huge problem, but the error message does kind of break the layout a bit.
I believe that tailrank is having some issue with their feed. What’s showing up is actually the cached version of the feed that SimplePie has locally. I’m getting the same error, but haven’t had time to diagnose.
If you want to, try to grab the rss feed itself and see if it parses correctly (either via a RSS validator or just by looking at it)
Thanks for the prompt reply. To get around it yesterday, I actually just commented out that error message in simplepie.inc down around line 1672, if I remember right.
How do I ensure I am caching feeds? I’ve reduced the number of feeds and it still takes like 6 or 7 seconds for the page to load.
Is it possible to speed up the rendering of the page? I’ve noticed NOTHING renders until EVERYTHING renders.
Ideally, I think you’d want some sort of “loading” animation going for each feed and each animation is replaced with the feed once it comes in.
I’m a little pressed for time, so I didn’t do the exact research, but I believe the simplepie documentation tells you how to set the caching parameters per feed as a parameter. There should also be some configuration parameters about caching that you could find useful.
I have seen a demo with loading placeholders linked off the simplepie website.
Sorry that I’m a little pressed for time, but I wanted to get you going on the right direction
Thanks much!
If I am getting the error ” cURL error 7: couldn’t connect to host ” at the end of the last row, does it means that I have php extension curl enabled? If so, how can i disable it.
Thanks for response
you do have the extension enabled - the error message is one that indicates the webserver you are connecting to is down or reporting a 404. Easiest way to get rid of it is to check that feed is at the URL you are pointing at. If that doesn’t work, then you can remove the feed totally. Disabling cURL will disable all of the functionality
Hi,
Thanks for the guide. I have installed SimplePie and the newsblock demo, however I am getting the following error:
“cannot yet handle MBCS in html_entity_decode()”
… on all except the last feed “Lessig Blog (JP)”.
CHMOD for my “cache” directory is set to 777.
I’m trying to get it working here: http://www.zlect.com
Please help! Thanks a lot.
Hi,
Never mind, I got this problem resolved. It was caused by a bug in PHP4, and upgrading to PHP5 solved it.
Thanks!
Thank you so much for sharing this. It is WONDERFUL. I noticed that if there is an error in the XML or the FEED that the error line can be long enough to mess up the layout. Is there anyway to get the errors to be displayed within a div that could be styled (making the print smaller, for example)?
And what is the protocol if someone’s feed is generating an error? Is it considered good manners to let them know about it?
Thanks again for a wonderful product. (Dropped it on my IIS 5 (with PHP5/ISAPI) and it just worked!
I believe feed errors are captured in the php/includes/newsblocks.inc file at Line 39 where the code reads “echo $feed->error();” You should be able to put some markup (like divs) into that echo statement (see php tutorials on how to do that).
Alternatively, I believe you can look for the error statements inside php/includes/simplepie.inc and throw your markup in there.
The right place to ask this would be in the simplepie forums on simplepie.org
great script, have it up and running a treat!
I am trying to figure out how to display the image that comes with the first news item on the feed. Any ideas??
Take a look at the flickr section in php/includes/newsblocks.inc That should give you an idea of how to parse images in the RSS feed
How can i set the more >> stay in intact when more news drop down instead of more >> pushes down?
I’m not sure what you mean by “intact” - can you elaborate? Do you want the “more” link to stay where it is when it’s expanded?
Im sorry if im not clear… can we talk thur email cause i might want u do some fixes for me so hope hear from you soon
I couldn’t find a code that do the trick by ” more>> changes to less>>” how can i find that source to copy and paste on new version of newsblock, hope hear from you soon thanks.
Thanks for answering my previous question. I have another:
What version of SimplePie did you use for this?
If I want to drop in a newer version of SimplePie, what part should I replace? Thanks for any reply!
I used 1.1.1. I believe you should be able to drop the simplepie newsblocks stuff into the php folder. I have not examined the differences between 1.1.1 and the latest version, so ymmv. Also, make sure to look at the included javascript files for any major differences.
Good luck!
I uploaded ur script and it works well but I want to understand the ping part (set to delic.com/news?p=1) and also a feed was parsed with extra html tag been displayed any ideas?
Guys,
Can anyone give me any advice on how to control the number of topics listed from the script. For example I only want the first topic from each feed.
Thanks, great script!!!!
yup, pass the items variable in the newsblocks::render code - so something like: newsblocks::render(’http://del.icio.us/rss/’,array(’items’=>1));
I believe this will do it. If not, read the simplepie documentation for passing variables to the render function
That didn’t work, but I found this:
Set the max number of items per feed to return with Multifeeds
$feed = new SimplePie();
$feed->set_feed_url(array(’http://simplepie.org/blog/feed/’, ‘http://images.apple.com/main/rss/hotnews/hotnews.rss’));
$feed->set_item_limit(5);
$feed->init();
$feed->handle_content_type();
echo $feed->get_title();
Not sure where or how to implement this script.
Thanks for the help!
rshah21,
Your code worked…
Thanks!!
Is it possible to set a hard limit on items pre-fetched? I see I can use array(’item’ => 10) but this still pre-fetches the reminder of the items which I’d like to set a limit max 10..
Thx
1.) are you using ‘item’ => 10 or ‘items’ => 10
2.) Based on a quick glance at the documentation on simplepie.org I’m not sure that the code is prefetching the entire feed and then only rendering the first ten items when using the ‘items’=>10 option. The item value is passed into this code in newsblock.inc
if (isset($options['items']))
{
$items = intval($options['items']);
}
else
{
$items = 10;
}
foreach ($feed->get_items(0, $items) as $item)
{
$class = ”;
$type = ”;
$new = ”;
Examination of the code and the documentation seems to indicate that the feed it not pre-fetched and then parsed - it appears that a handler is opened, and then the feed is parsed item by item until the max limit is reached. I could be wrong (there’s a significant probability of that), but I believe that setting ‘items’=>10 will do what you want it to do
I can’t seem to get the “More” buttons to work on my site. Doesn’t appear to be working on yours either. Any tip on fixing that?
GREAT package by the way. It’s so nice to not start from scratch on something like this.
Sorry, scratch the last one. It is working on yours. Can’t figure out what the problem on mine is. I haven’t messed with the code.
I think I may not have rolled this fix into the zip file. I’ll update it this weekend, but if you’re comfortable with php, CSS and javascript, the place to look is in php/includes/newsblock.inc In there the “more” link is inserted with a style called “direction:” I think that when I inherited the code, the style name was incorrect. In any case, I’ll pull together a replacement zip file of the current code and upload that, which should fix the problem
Very nice. I’ll see if I can clean it up myself too.
On the updating side. I’ve seen a few sites like this with an alternate stylesheet option (choose light or dark) and text resizing (larger or smaller) in the top right corner. That’d be a sweet addition. I might try and hack it together myself, but it’d be a nice add to a packaged zip.
How do you get the “more” slider link to change to something like “less” when it is expanded?
Hi. I updated the zip file with the source of the current news.delic.com site, where the More link works. Remember that the link will only work if the cache has more than 10 items, otherwise the page will just reload
Thanks!
Out of curiousity, is there changes to the index.php that make this work? Or just other files?
index.php, js/newsblocks.js and I believe php/includes/newsblocks.inc
Leave a reply