scriptygoddess RSS Feed
 
 
 
 

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!

21 Responses to “blogroll in columns”

  1. 1
    Miss Anthropy:
    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…

  2. 2
    Wizbang:
    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…

  3. 3
    Crumbs:
    Blogroll List in Columns
    Blogroll Lists in Columns

  4. 4
    Lunanina.com:
    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…

  5. 5
    Laura:

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

  6. 6
    JLT:

    That is great! thanks.

  7. 7
    Kevin:

    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.

  8. 8
    theresa:

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

  9. 9
    Kevin:

    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 <

  10. 10
    theresa:

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

  11. 11
    Kevin:

    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?

  12. 12
    Kristina:

    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?

  13. 13
    Jill:

    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.

  14. 14
    Kristina:

    So how do you add tr and table tags?

  15. 15
    Kevin:

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

  16. 16
    theresa:

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

  17. 17
    Jill:

    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!

  18. 18
    Annessa:

    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.

  19. 19
    Jill:

    This is awesome!! Thank you!!!

  20. 20
    Jill:

    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!

  21. 21
    Tom Keating:

    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.

Categories

Archives

Bookmarks

WordPress Resources

Meta

ADVERTISEMENTS