I know that this is something that can be accomplished with the Category Module, but I prefer Drupal's Taxonomy and I don't want the complexity of the Category module's container/category options.

What I would like (ideally) is a module that creates a checkbox when you create a new node that says something like "Create a term with the same name" that automatically creates a Taxonomy Term with the same name as the node title. Ideally, you could choose to have the Content Type be the Vocabulary that it gets added to, or you can select a parent Vocabulary/Term (like a 2-option radio selection, with further inputs if the latter is chosen). The module would also automatically tag the node with its own term so that selecting that term would include the "title node" along with other tagged nodes. A nice extension would be to automatically list the "title node" at the top of its listing.

I recognize that this is essentially what the Category module does if you make a content type or node behave as a category, but I really like the way Taxonomy provides easy buttons to list everything under a specific term with easy links, and I am already using Taxonomy for certain types of categorization. Basically, I think it becomes confusing if you use both Taxonomy and Category on the same site, and I would prefer to use Taxonomy only.

Is there a module that already does this, using Taxonomy instead of Category?

Comments

white-raven’s picture

*nudge*

Is there no one with sufficient knowledge about Taxonomy + Category to comment on this? Even a comment with some certainty that this doesn't exist would be helpful.

-- White Raven

nevets’s picture

Have you looked under http://drupal.org/project/Modules/category/71, there are some module that may help or at least serve as a starting point for a custom module. What you are after would not be hard to code as a module but I do wonder what the benefit would be unless you expect titles to repeat a lot (otherwise you end up with a lot of unique terms)

white-raven’s picture

Thanks for the link! It looks like Node Auto Term [NAT] does what I want, but I'm getting an "Unable to connect to database server" message when I click on the module's page... Oh well, at least the download works. Here's hoping the 6.x-1.1-beta isn't too buggy.

Out of interest (and in case NAT fails me), can anyone name or point me toward the documentation for functions related to manipulating taxonomy?

Thanks again for the helpful responses.

-- White Raven

lyricnz’s picture

You could just look at the source of modules/taxonomy/taxonomy.module to see the PHP for yourself. Alternatively, this file is used to auto-generate the documentation you can find at http://api.drupal.org/api/file/modules/taxonomy/taxonomy.module/6

lyricnz’s picture

If you don't find anything, this would be about five lines of code in a custom module.

lyricnz’s picture

Node Auto Term module looks like it might do the trick for you. Otherwise, if you're comfortable with module development, you can just watch for "presave" on your nodetype, in hook_nodeapi. Here's an example, for "story" node type, that uses a system setting 'test_autotag_vocab' to determine which taxonomy to update.

/**
 * Implementation of test_nodeapi.
 */
function test_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'presave' && $node->type == 'story') {
    $target_vid = variable_get('test_autotag_vocab', 0);            // get the taxonomy vocab to add to
    $terms = $node->taxonomy['tags'][$target_vid];                  // get the current terms
    $title = str_replace(',', '', check_plain($node->title));       // remove commas

    // let taxonomy module take care of removing duplicates
    $node->taxonomy['tags'][$target_vid] .= ','. $title;
  }
}

If you're going down this path, let me know, and I'll paste the rest of the module - I wrote it while you added the NAT comment :/

white-raven’s picture

Thanks for the example!

I've been away from Drupal development for a while and it's still how I remember: flexible and easy to use--you just need to know how to access the data you're looking for.

I've been reading the NAT module, and I think I'm going to use a modified version of it. I'm going to contact its maintainer and ask whether I can help them update to Views 2.x (the current Beta still has the old Views implementation), as well as possibly adding a new feature...

In the past there have been issues adding a same-named node to its own vocabulary term. However, as far as I can tell, the whole point of the same-name term is to relate other nodes to the same-name node. I want to add a feature that, without having to associate it with the term, the same-name node automatically appears as the first node in the same-name term's list; of course, you'd be able to turn this bahaviour off if you wish. This can be accomplished by modifying the taxonomy_term View (once NAT integrates with Views 2.x), or by extending the NAT module to be configured to "step in" whenever a NAT term page is being compiled.

Anyway, it looks like that's where I'm headed. Thanks for all the tips everyone!

-- White Raven