Blogger Tags

Well, I wrote a quick PHP script to create a list of tag links that I could display on this page. It should be over to the left. The code is pretty simple:

<?php
$dirname = ".";         # current directory
$dir = opendir($dirname);

while (false != ($file = readdir($dir)))
        {
        if (ereg(".html$", $file))
                {
                $tag = substr($file, 0, strlen($file)-5);
                $file_list .= "<li><a href='/labels/$file'>$tag</a>";
                }
        }
closedir($dir);
?>
<h1>My Tags</h1>
<ul>
<?php echo($file_list); ?>
</ul>

I don’t have the tags showing in any particular order yet, but they’re all there. I just saved this code to a file in the labels directory on my server, then included it in my template with a server-side include.
Also, I should mention that I used this page to format the source code above so it would look OK in a blog post. (Hopefully, it *does* look ok…)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.