scriptygoddess

28 Jul, 2003

blogroll in columns

Posted by: Jennifer In: Scripts

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!

21 Responses to "blogroll in columns"

1 | Annessa

July 29th, 2003 at 2:39 am

Avatar

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.

2 | Jill

July 29th, 2003 at 10:09 am

Avatar

This is awesome!! Thank you!!!

3 | Jill

July 29th, 2003 at 10:32 am

Avatar

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!

4 | Jill

July 29th, 2003 at 10:36 am

Avatar

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!

5 | theresa

July 29th, 2003 at 1:11 pm

Avatar

Glad you got it figured out Jill! Those table tags are pretty important… I probably should have included them in the script.

6 | Kevin

July 31st, 2003 at 11:20 pm

Avatar

This is soooo much better than the sidebar technique. I'm off to make a whole blogroll page with multiple columns. Thanks.

7 | Kristina

August 2nd, 2003 at 1:14 pm

Avatar

So how do you add tr and table tags?

8 | Kristina

August 2nd, 2003 at 1:39 pm

Avatar

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?

9 | Jill

August 2nd, 2003 at 5:40 pm

Avatar

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.

10 | Kevin

August 2nd, 2003 at 11:46 pm

Avatar

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?

11 | theresa

August 3rd, 2003 at 1:07 am

Avatar

Kevin, I'm not really following what you're saying. Are you asking for a PHP script that alphabetizes your blogroll links?

12 | Kevin

August 3rd, 2003 at 1:17 am

Avatar

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 <

13 | theresa

August 3rd, 2003 at 10:38 am

Avatar

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. :)

14 | JLT

August 4th, 2003 at 10:40 am

Avatar

That is great! thanks.

15 | Kevin

August 10th, 2003 at 2:38 pm

Avatar

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.

16 | Laura

March 15th, 2004 at 3:28 am

Avatar

Perfect hack!! I love it! Thanks so much!

17 | Crumbs

August 5th, 2003 at 10:15 am

Avatar

Blogroll List in Columns
Blogroll Lists in Columns

18 | Lunanina.com

August 10th, 2003 at 2:10 am

Avatar

The Magic Behind the Curtain
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…

19 | Wizbang

August 10th, 2003 at 3:56 pm

Avatar

How To Make A Separate Blogroll Page In PHP
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…

20 | Miss Anthropy

August 15th, 2003 at 7:56 pm

Avatar

Random
– 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…

21 | Tom Keating

July 27th, 2004 at 11:22 pm

Avatar

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.

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements