“Professional service
that won't make you nervous”

Macintosh  Perl  Linux

WordPress Projects

I've recently done a good bit of development with WordPress, in the course of which, it became necessary to write a plugin. Other things may follow, it depends on whether I do more work with WordPress in the future, after the completion of the current project.

Since I've written a plugin for WordPress that has general usage beyond that of the original client, and particularly since I couldn't for the life of me find anything else that did the same thing the way I wanted it to work, it behooved me to release it to the wild and let you all go nuts with it. Therefore, here's where you can download it, read about it, and send me questions and fixes for it.

WordPress Plugin – WDN-Directory-List

Description:

Screenshot
Sample Screenshot

Lists an arbitrary directory of files in a pretty-print format, such as a PDF library, or a folder full of downloadable files not otherwise viewable with a browser. Requires a WP Page template, as you can have the Page post appear above the file list describing the contents. The custom field WDN_Directory will hold a per-Page value of the directory that you wish to display (must be in your webserver's directory). Sub-directories and symbolic links will be ignored; use additional Pages for those. You can set a unique header for the listing with the custom field WDN_Directory_Title.

While editing your Page content normally, you'll need to add the function
<?php wdn_list_directory(); ?>
to your Page Template in order for this to work.

Your WP Page template could be built with the following example content to include both the Page's post as well as the directory list: (although you'll need to include your own sidebars, headers, footers, and other theme content yourself)

<?php
/*
Template Name: Custom Directory Listing
*/
?>
<div id="content">
    <div id="page">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <h1><?php the_title(); ?></h1>
            <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
            <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
        <?php endwhile; endif; ?>
    </div>
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>

    <?php wdn_list_directory(); ?>
</div>
				

This plugin requires the use of one to two Custom Fields that you add and set values for, while editing your Page content in the admin interface.

  • WDN_Directory should hold an absolute path relative to the webserver document root, such as /library/docfiles/ for files in http://serverurl/library/docfiles/
  • WDN_Directory_Title [optional] should contain your preferred header markup as well, such as <h2>Your Title Here</h2>, but will default to a standard heading if you leave it out.

Additionally, some CSS markup is inserted into the head section of the final Page output by WordPress, to pretty-print the directory list a little, and you can edit that within the plugin itself if you need to.

The plugin also includes a set of icons (kept within the plugin directory) to aid in labelling the files for download.

Installation

To install the plugin, extract the archive to the wp-content/plugins/ directory intact, as a directory itself. Your /plugins/ directory in your WordPress install should contain the files thusly: /plugins/wdn-list-directory/wdn-list-directory.php and the icons should be within the same directory as /plugins/wdn-list-directory/icons/*.gif files. File (0644) and Directory (0755) Permissions will need to be set accordingly, as you likely already know.

Download

You can download the latest version here.

Version

The current version, 1.1, was released March 17, 2006; fixing a few cosmetic issues in Firefox.

The previous version, 1.0, was released March 16, 2006

This is my first plugin for WordPress so don't be too harsh with me if it doesn't work like you expect. I'm open to suggestions for improvements. :-)

Kudos

Many thanks go to 'undersigned', 'Viper007bond' 'MarkJacquith', 'BigJibby', and 'shep' of the freenode.net #wordpress channel for their assistance and support during the making of this plugin.