Tags: An Implementation June 26, 2005

Theron Parlin

After meeting Jonas Luster and having him take me behind the curtain of the great and powerful OZ to show me some of the goodies he’s got under the hood of jluster.org, I decided to implement one of his neat features on Thought Mechanics. I’m referring to the tag box in the upper right side of the permalink pages.

The tag box is really cool because it allows for logged in users to add tags and for users with higher user levels to delete tags, all on the fly from the permalink page. The way Jonas has it set up is that creating a tag will create the category if it doesn’t already exist and assign it to the current post. If the tag already exists, it skips the creation part and just assigns it to the current post. Deleting a tag will remove the category from the post and it will delete the category if no other posts are assigned to it.

Jonas never showed me any of the code for this functionality, so the implementation is my own. As a result, I decided to implement my version with one difference. I don’t delete the category if there are no posts assigned to it. The reason is because deleting a category won’t free up the ID, so it’s sort of pointless, especially since the same tag might get created more than once.

For instance, a tag called “pets” might get created using an ID of 24. Once you delete the tag “pets,” the ID is now no good to you. If you were to create the tag “pets” immediately after deleting it, Wordpress would give it the ID of 25. So, my implementation actually saves you category IDs–not that it really matters, but hey, isn’t efficiency nice? Of course, the downside is that you could end up with a bunch of unused categories lying around over time if you’re not careful.

I also added some nifty JavaScript code to allow users to shrink the box if they so desire.

Okay, so the implementation. You’re welcome to download the implementation, although support for it will be very limited. The php file provided is the entire single.php for Thought Mechanics, in tact. I think the best way for someone to see how it works is to just view that file. Good luck.

Article printed from Squible: http://www.squible.com
URL to article: http://www.squible.com/2005/06/26/tags-an-implementation/

    7 Responses to “Tags: An Implementation”

  1. April June 27th, 2005 at 10:42 am | Permalink

    Is this a new plug-in?

  2. Theron June 27th, 2005 at 10:44 am | Permalink

    No, It’s not a plugin, but if someone wants to take what I wrote and turn it into a plugin, that might be neat… What I’ve provided is the single.php file from thoughtmechanics.com so that people can either use it the way it is, or modify it for their needs.

  3. Theron June 28th, 2005 at 9:57 am | Permalink

    Update: You might have to add this code somewhere near the top of your file depending on your PHP installation:


    <?php
    if ($_POST['action']) {
        $action=$_POST['action'];
    } else {
        $action=$_GET['action'];
    }
    ?>

  4. Tagging Other’s Blogs | Binary Bonsai Archive June 30th, 2005 at 3:23 am | Permalink

    […] gs as easily as it is done on flickr. Please Bunny, help me! Update: Anyone up for taking Theron Parlin’s tag code, cleaning it up a bit and creating a plugin? […]

  5. A Serendipitous Intention » Blog Archive » Weekly Roundup July 14th, 2005 at 11:02 pm | Permalink

    […] There is potential out there for a really great new plug-in for WordPress that would allow for tags. I don’t know if I would use tags or not, but I think it’d be a great plug-in for someone to finish. […]

  6. Emily Hambidge July 14th, 2005 at 11:04 pm | Permalink

    I posted about this here

  7. card credit number validation May 2nd, 2008 at 3:13 am | Permalink

    nokia ringtones free ringtones for nokia phone ringtones for nokia phone…

    Play canada credit card online application mobile credit card wireless service…


Leave a Reply

This entry was posted on Sunday, June 26th, 2005 at 8:22 pm. You can follow any responses to this entry through the RSS 2.0 feed. If you're wondering how to get your own icon next to your comment, go visit gravatar.com and get yourself hooked up.