I have been looking for a way to create new taxonomies within the node creation process. I notice there used to exist a module taxonomy_otf but that died out before Drupal 4,7...

Single Select Free Tagging describes the kind of thing I am looking for but there doesn't seem to be anything like this?

I was thinking about how this could be implemented and playing around with jQuery, and thought this would be a good solution.

The basic concept would be that we add an "Other..." to the end of each list using something like:

$("select").append("<option value='-1'>Other...</option>");

Then use something like this to trap the selection of Other:

$(function(){
  $("select.form-select").change(function(){
   var value;
   var cat;
   value = $("select#edit-taxonomy-3").attr('value');
   if(value==-1){cat=prompt("New Category");}
	$("select.edit-taxonomy-3").append("<option value='-2'>"+cat+"</option>");

  })
})

Then we could either use prompt or slide in another form in which to enter the new category.

Then we would need to feed this into the taxonomy, and reload that selection box...

Anyone have any ideas how I could actually turn this idea into a working module??

Thanks
Andy

Comments

dman’s picture

Taxonomy on-the-fly became "Free Tagging" in core for version 5.
You'll find it already is available, built-in, when you edit the appropriate vocab.
It uses auto-complete.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

andykemp’s picture

The problem is I don't want free-tagging. I want to limit the taxonomy to thos I have created, so that the users can select from the list. But in the event they need a new taxonomy, I don't want them to have to go through all the menu's to add one. I also I want to maintain the hiarachy, and that as far I can tell isn't possible in free tagging...

Any one have any ideas how I could make this work?

Thanks
Andy

http://www.1kemp.co.uk

stormer’s picture

In a mad rush the other day I seemed to have ended up with something like this but I have not for the life of me been able to replicate it. It's driving me insane. Pleeeeease someone help.

rleddy’s picture

Hi,

I just implemented a thing like this a little while ago, (last month?)
Basically, when you create the node you see a tree from which you may select terms, either to classify or to be the parent term.
If you add new terms, then on submission, the terms are added to the selected parent in the taxonomy.
So, the tree grows as you make new content.

Initially, I made the component as part of CCK.
But, now I am going to use ROLLED OATS. So, in a day or two, I am going to recreate this component as a ROLLED OAT.
This new component will be used to fetch the fields that are determined to be part of the content given the new classification, so that the form will update to include the new data entry fields as soon as the classification is done.

At any rate, someone suggested that I send up a diff for changes to the taxonomy module that I made so that the node entry can grow the taxonomy tree.
I seem to be always short of time to make these formal submissions. I sent in the code on an issue in a code section. And, typing this is faster than setting up the DIFF process.
But, I guess I will get to it sooner or later. Maybe, I will have to do this when I make the new ROLLED OAT.

So, if you are interested in this please let me know. Right now the best way to do this is to post a message at www.classydex.com. (This is also going through an OAT revision, because the tree section stolen from O'Reilly doesn't work in IE, so I will use one from OAT. But, if you are using Mozilla, you can classify your message as deeply as desired on classydex. And, I will take a look there.)