WordPress.org

Ready to get started?Download WordPress

Forums

del.icio.us style tags/categories? (14 posts)

  1. kellan
    Member
    Posted 9 years ago #

    has anyone written a WP plugin to make categorization more like del.icio.us style tagging?
    at the most basic i'm just looking for a text field on the posting screen where categories can be typed in as either a comma or space separated list, and are auto created if they don't exist. (i've got some code to do auto category creation in my wp-aggregator if anyone wants a jump start)
    future refinements could be added (e.g. support for "related tags" ala del.icio.us)
    anyone done it, or interested in doing it?
    thanks

  2. sunshine
    Member
    Posted 9 years ago #

    I was thinking of this myself, but decided to just tinker with the existing categories, but call them "keywords". I prefer that, since I find categorization of posts difficult. Whether the logic is really all that different, I have no idea, but that works for my brain.
    I'd be interested in your auto-generate non-existing categories though. :)

  3. kellan
    Member
    Posted 9 years ago #

    sunshine, i think the underlying implementation would be largely identical, its more of a UI question, exception for the auto-generation of categories.
    the following code is what I use in wp-rss-aggregate, it takes a list of category names, and returns a list of category ids, first creating any which don't already exist. (i'm not sure how well pasting in a large code block is going to work, if it gets munged you can find it at the above url)

    // look up (and create) category ids from a list of categories
    function lookup_categories ($wpdb, $cats) {
    if ( !count($cats) ) {
    return array();
    }
    # i'd kill for a decent map function in PHP
    # but that would require functiosn to be first class object, or at least
    # coderef support
    $cat_strs = array();
    foreach ( $cats as $c ) {
    $c = $wpdb->escape($c); $c = "'$c'";
    array_push($cat_strs, $c);
    }
    $cat_sql = join(',', $cat_strs);
    $sql = "SELECT cat_ID,cat_name from $wpdb->categories WHERE cat_name IN ($cat_sql)";
    $results = $wpdb->get_results($sql);
    $cat_ids = array();
    $cat_found = array();
    foreach ( $results as $row ) {
    array_push($cat_ids, $row->cat_ID);
    array_push($cat_found, $row->cat_name);
    }
    $cat_unknown = array_diff($cats, $cat_found);
    if ( count($cat_unknown) ) {
    $sql = "INSERT INTO $wpdb->categories (cat_name, category_nicename)
    VALUES ('%s', '%s')";
    foreach ( $cat_unknown as $new_cat ) {
    $nice_cat = sanitize_title($new_cat);
    $wpdb->query(sprintf($sql, $new_cat, $nice_cat));
    array_push($cat_ids, mysql_insert_id ($wpdb->dbh) );
    }
    }
    return $cat_ids;
    }

  4. sunshine
    Member
    Posted 9 years ago #

    That's some nice code there. :) Could be made ever-so-slightly faster by using [] instead of array_push(), but I don't think the speed would be much different, right?
    Thanks for sharing, kellan. I'll have to try and corner someone -- a few peeps will take suggestions for plugins, etc, so maybe we can smile sweetly and get it packaged up nicely into the admin post ui. :)

  5. chuyskywalker
    Member
    Posted 9 years ago #

    I'd be happy if in the "Category" section of the post page there were three empty spaces (text boxes) for new categories.
    :)

  6. raster
    Member
    Posted 9 years ago #

    Ooh, this is something I'd really like to see too. I'm all for some sort of 'on the fly' category/tag creation...

  7. caek
    Member
    Posted 9 years ago #

    Me too!

  8. kellan
    Member
    Posted 9 years ago #

    I did some rough work on enabling this tonight. It works, and I'm pretty happy with it, but its currently a direct patch rather then a plugin.
    I put up some thoughts on tagging in general, and some notes on the patch.
    Its about 2am here, so it might not be coherent.

  9. sunshine
    Member
    Posted 9 years ago #

    Thanks so much for sharing, kellan. I'll be trying this out as soon as I can and give you feedback, if you'd like?

  10. naelyn
    Member
    Posted 9 years ago #

    I think I have a fairly useful solution that I just finished today:
    http://chaotic.nexusvector.net/archives/2005/01/16/wp-tags/

  11. kellan
    Member
    Posted 9 years ago #

    latest version of tags code is at: http://laughingmeme.org/tags4wp/

    mostly a plugin this time, though i had to add a few "missing" hooks

  12. flamk
    Member
    Posted 9 years ago #

    I've been fooling around with Kellan's "mostly" plugin, and am really happy with the way it works. However, I noticed that when the plugin is activated and I make any changes to my static pages, I get the following errors:

    Warning: Invalid argument supplied for foreach() in /wp-includes/template-functions-category.php on line 410
    Warning: in_array(): Wrong datatype for second argument in /wp-includes/template-functions-category.php on line 414

    So, to avoid the errors when updating static pages, I simply turn off Kellan's plugin, make the changes, and then turn it back on again.

  13. carla
    Member
    Posted 9 years ago #

    I'm setting up internal keywords/tags as supplements to categories (and as a way to unify my three WP installs) thanks to Jerome's Keywords: http://vapourtrails.ca/wp-keywords. And I am so thankful...!

  14. jxpx777
    Member
    Posted 9 years ago #

    Take a look at Felix Wong's Tags plugin. You can find it on his site http://boke.name/ or in wp-plugins.org. I am still having some minor troubles with it, but it is going to be really nice when it finally works. It works great on his site however so you can see it in action there.

Topic Closed

This topic has been closed to new replies.

About this Topic