blogroll in columns
With the new layout of my site, I wanted something other than the traditional mile long blogroll column in a sidebar. More specifically, I wanted to break my blogroll into columns. With a little code from blogrolling.com;, I was able to whip up a PHP script in no-time to do just that.
All you need is a PHP enabled weblog, and a blogroll. Once you have your blogroll URL (the PHP URL provided for you by blogrolling), paste it into the value of $url. Next, adjust the $column_size (number of links in a column) and $column_width. Then surround the code with table and tr tags, and you’re done!
<?php
// replace the value of $url with your own link
// from the code generator
$url = “paste your blogroll url here”;
$count = 0;
//adjust column_size and column_width
$column_size = 20;
$column_width = 175;
echo “<td width=\”$column_width\”>”;
if ($my_blogroll = @fopen(”$url”, “r”)) {
while (! feof($my_blogroll)) {
$blogroll = fgets($my_blogroll, 255);
echo “$blogroll”;
$count++;
if($count >= $column_size) {
echo “</td>”;
echo <td width=\”$column_width\” valign=\”top\”>”;
$count = 0;
}
}
} else {
echo “<td>”;
echo “ERROR: Blogroll is currently inaccessible”;
echo “</td>”;
}
echo “</td>”;
?>
The way the code is configured now, it will create columns with 20 links in them that are 175 pixels wide. You can see my columnized blogroll here;. If you have any problems, leave a comment and I’ll try to help you out!
July 29th, 2003 at 2:39 am
Dude, this is perfect for my bookmarks page, where I have many links to go through. Thanks Theresa! I’ll let you know how it works.
July 29th, 2003 at 10:09 am
This is awesome!! Thank you!!!
July 29th, 2003 at 10:32 am
Uh oh… having a problem. LOL First I was getting a parsed error but it turned out there was a ” missing in line 55? Fixed that. But now… it isn’t creating the rows. I tried changing the numbers for the links and column widths but still not working. Any ideas? Thanks!
July 29th, 2003 at 10:36 am
Sheesh, I spoke too soon… figured it out. Wasn’t creating the table and tr tags. I added those and it is fine. LOL Thanks!
July 29th, 2003 at 1:11 pm
Glad you got it figured out Jill! Those table tags are pretty important… I probably should have included them in the script.
July 31st, 2003 at 11:20 pm
This is soooo much better than the sidebar technique. I’m off to make a whole blogroll page with multiple columns. Thanks.
August 2nd, 2003 at 1:14 pm
So how do you add tr and table tags?
August 2nd, 2003 at 1:39 pm
Sorry, i’m dumb, I’ve surrounded the code with table and tr tags, but it keeps saying a ‘, or ‘; is missing in line 48…what does that mean?
August 2nd, 2003 at 5:40 pm
Kristina… At the time, I just added them around the script but if you want to place them INSIDE the script itself, you can just add the ‘echo’ lines like you see for the </td> at the end.
August 2nd, 2003 at 11:46 pm
OK this is nice, but I’ve got a request of a little more advanced operation… I show by blogrolling.com blogroll by most recently updated and limit it to the top 75 or 100. The whole list is around 180 sites. What I’d like to be able to do with the script above is to sort them alphabetically for display on a Full Blogroll page without having to modify the settings on the blogroll.
Any ideas?
August 3rd, 2003 at 1:07 am
Kevin, I’m not really following what you’re saying. Are you asking for a PHP script that alphabetizes your blogroll links?
August 3rd, 2003 at 1:17 am
Since I’m not using the blogroll on the main page in alphabetical order, yes I’d like to sort the incoming rows alphabetically within the script.
The other issue is that Blogrolling only sends you the display maximum (if you use that option) not the whole list, so I’ve taken that up with them. Nothing your script can do about that…
BTW - the
echo <td width=\”$column_width\” valign=\”top\”>”;
line is missing a quote before the <
August 3rd, 2003 at 10:38 am
Aha, I must have missed that quote when I copied and pasted. Thanks.
I’m sure the alphabetizing can be done. I’ll see if I can make it in the next few days or so.
August 4th, 2003 at 10:40 am
That is great! thanks.
August 5th, 2003 at 10:15 am
Blogroll Lists in Columns
August 10th, 2003 at 2:10 am
I just wanted one central place where I could record all the little dodads that make this site tick. Plugins MT Paginate MT Entry If Comments Global Listings MT Other Blog Smarty Pants Simple Comments Archive Date Header Word Count…
August 10th, 2003 at 2:38 pm
Jason at Blogrolling.com let me in on this little tip:
If you put &showall=1 at the end of your “$url =” string the entire blogroll will be returned. This is handy if you are using the How many links to display option for your blogroll. That feature is only available to Blogrolling Gold members.
Still waiting to hear back if there as an override parameter for the Sorting your links preference so you could display the blogroll table alphabetically for blogrolls not currently being sorted that way (i.e. displayed normally in priority, random, or update order). I’ll post an update on this when I get one.
August 10th, 2003 at 3:56 pm
I just put up a post at WizbangTech on how to make a separate page for your Blogrolling.com blogroll in PHP. Thanks to Theresa for the code in this ScriptyGoddess tip and Jason at Blogrolling.com for the tweak to show…
August 15th, 2003 at 7:56 pm
- Victorian Sex Cry Generator (sent by Moira — merci!) - A php script for columned blogrolls (at Scriptygoddess) - A cowboy’s tale, part 1 and 2 (featuring me as a cowgirl! boggle) It was indeed a memorable spectacle: a…
March 15th, 2004 at 3:28 am
Perfect hack!! I love it! Thanks so much!
July 27th, 2004 at 11:22 pm
scriptygoddess,
i’m trying to get my bloglines.com blogroll to bold the category heading in my blog and I thought you could help.
http://blog.tmcnet.com/blog/tom-keating
I can’t seem to figure out why the stylesheet to make the blogroll categories BOLD and subfolders NOT BOLD isn’t taking effect. I’m using bloglines.com’s Javascript code inserted into my default template just above Links.
i.e. <script language=”javascript” type=”text/javascript” src=”http://rpc.bloglines.com/blogroll?id=tkeating”></script>
i know .css very minimally, so i’m sure it’s something simple. The entire blogroll (Javascript) is enclosed with a tag that has a class=’blogrollmain’ attribute. In addition, the folders have tags with a class=’blogrollfolder’ attribute.
Knowing that, below are the 2 styles that I added to styles-site.css in MovableType 2.661. However it didn’t seem to apply the style. Suggestions?
2 styles added:
.blogrollmain ( font-family:palatino, georgia, verdana, arial, sans-serif; font-size:small; color: #666; border-bottom:1px solid #999; margin-top:20px; font-weight:bold; background:#FFF; }
.blogrollfolder ( font-family:palatino, georgia, verdana, arial, sans-serif; font-size:small; color: #666; border-bottom:1px solid #999; margin-top:20px; font-weight:normal; background:#FFF; }
Thanks.
p.s. used lots of your other tips. Great site! I’ll have to trackback to some of them.
p.s.s. I’d use your php code for blogroll, but running MT on Win2K IIS with ActivePerl.