Chris Brauer Media Project [BLOG]

IDEAS FROM POP CULTURE TO POLITICS, TECHNOLOGY, PHILOSOPHY, BUSINESS, MEDIA, SPORT, AND LIFE

This is my personal blog for friends and family.

Tuesday, January 09, 2007

Blogger Guide to FTP Labels

It is odd what gets you inspired to blog again ... and again ... and again. Everyone knows that the trick to succesful blogging is to write quality posts frequently. But sometimes it is just not interesting enough to participate regularly and the Blogger revamp addresses a key issue in opening up the imagination of 21st century bloggers.

Tags have long been an innovative form of taxonomy. Let the users define the terms is a sharp turn from the controlled thesaurus prevalant in so much corporate software. But the successes of Wikipedia and Technorati amoung others has opened up a new set of terms for meta (information about information) tags and descriptors.

In Blogger what is really cool about the idea is that authors can add tags to content and have these "Labels" (categories or tags in disguise depending on your perspective) appear on the site, providing visitors with a crucial piece of access and navigation. Users of tools like Movable Type will be familiar with the ability to create categories for posts but allowing for unlimited terms to describe content extends this concept further.

The following is a guide for how to insert a list of Blogger Labels on every web page of your FTP hosted Blogger blog (like on the right side of this blog under the heading 'Labels'). This interests those who use their own domain names as opposed to the blogspot.... urls of hosted Blogger. The new GUI for Blogger is largely only available to clients with the hosting solution but workarounds are very easy to create for those with domain names.

If you want to add Labels to your externally hosted Blogger blog follow these steps:

  1. Add a few Labels to blog posts. Just do a couple as these will be test labels. You can add labels at the bottom of each post. Seperate labels with commas, don't use spaces between words (underscores instead) but try and limit yourself to one word labels.

  2. Background Research. There are a couple of key blog posts on the Web for this idea at this time of writing. The first comes from David Nicholson (Where Magic Lives) in the form of a guide on how to include a "Label Cloud" of Labels where most frequently applied terms appear biggest and least referred smallest. The code for this example comes from a customized install of an exchange between David and a user in the comments at the bottom of the post. Meanwhile Andrew Huey was working on his own solution to getting labels on a left or right navigation as a PHP include. Another Good Source is Freshblog that lists some of the latest hacks available to hosted and unhosted alike.

  3. It is important to note if your blog posts use an .html extension (or other) or a .php extension. If you use a .html extension you must add the following code to your .htaccess file (ask your host if you don't know where this file is).

    AddType application/x-httpd-php .html

    If you are using a .php extnsion you don't need to add this info to the .htaccess file.

  4. Open up Notepad or another text editor. Copy and Paste the following code into Notepad and read step 3.

    <ul class="labels">
    <?php
    define('PREFIX', 'url prefix');
    define('SEARCH_DIR',
    'absolute path to Labels folder');
    define('THIS_FILE', 'cloud.php');
    if(file_exists(SEARCH_DIR.'_cloud_include_cache.html') &&
    filemtime(SEARCH_DIR.'_cloud_include_cache.html')>(time()-(60*60)))
    echo file_get_contents(SEARCH_DIR.'_cloud_include_cache.html');
    else
    {
    $output = '';
    $files = array();
    $dir = opendir(SEARCH_DIR);
    while($file = readdir($dir))
    if($file != '.' && $file != '..' && $file != THIS_FILE &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;& $file != CACHE_FILE)
    {
    $files[] = $file;
    }
    closedir($dir);
    asort($files);
    foreach($files as $name)
    $output .= "<li><span style='color:#990000'>----{-</span><span class='flower'></span> <a href='".PREFIX.
    htmlentities($name)."'>".
    htmlentities(str_replace('.php','',$name))."</a></li> ";
    echo $output;
    $fp = fopen(SEARCH_DIR.'_cloud_include_cache.html','w');
    fwrite($fp, $output);
    fclose($fp);
    }
    ?>
    </ul>


  5. You must customize this code for your Blogger FTP weblog. Customize the text url prefix with your own web page prefix for where the labels folder is on your server (eg. www.yourdomain.com/blog/labels would equal 'blog/labels'). Next put the absolute web path to your labels folder where the text in place of absolute path to Labels folder(eg' /www/www/...'). If you use a .html (or other extension) replace the .php code with your extension (eg '.html'). Consult your ISP or support documentation if you don't know this path. Optional is also to replace the color or style options on the appearance of the Labels list in your left or right column.

  6. Save the file as labels.php and FTP into a root blog directory on your server.

  7. Customize Template. Less effort here. Insert the following code in the right or left column of your blogger template as desired and read step 6.

    <h2 class="sidebar-title">Labels</h2>
    <p><?php include($_SERVER['DOCUMENT_ROOT']."location of .php file"); ?></p>

  8. Customize the formatting in the h2 class as required. You need to leave the second and third line but replace location of .php file with your location (eg. blog/labels.php).

  9. Test the output by publishing. You should see a list of Labels in Blogger. Other things to keep in mind are that you can delete the file (_cloud_include_cache.html) that will appear in your label directory if you want to see changes on your blog Labels list. This file is automatically created to make it so users will not reload the list everytime they visit the web page. The script is very easy on your server and only checks for changes every 60 minutes unless you delete the cache file.

For other interesting Blogger functionality Check out the Beautiful Beat guide to getting recent post functionality on Blogger FTP blogs and the Blogger comments guide (Blogkomm) on this site. Phydeaux3 (followed up by WebWeaver's World) offers an elegant Label Cloud for any Layouts Compatible Templates (blogspot. ... domains).

Labels: ,

CB || Email Story || [ 15 ] ||