Since there's no obvious way of saving term hierarchy when creating a node, this module was created.
The user creates 2 term reference fields, referencing the same taxonomy vocabulary.
Then, using this module you can set which field is the "parent" term and which one is the "child" term field. When saving the node, taxonomy terms are created and their hierarchy is saved.

Instructions on how to use:
a UI is not yet available but it's very easy to customize.

line 8 of term_reference_hierarchy.module
replace 'content' with your content type machine name.

line 9 of term_reference_hierarchy.module
replace field_tag_lvl_1 with the machine name of the field you want to declare as you "parent" term.

line 10 of term_reference_hierarchy.module
replace field_tag_lvl_2 with the machine name of the field you want to declare as you "child" term.

TODO: a UI that will allow selecting the parent and child terms as well as the content type.

link to sandbox: http://drupal.org/sandbox/aristeides/1202856

Comments

ccardea’s picture

The waiting time for a project application review is currently approaching six weeks. Please consider shortening your wait time by contributing to the code review process. All it takes is basic module writing skills, plus it is a great way to add to your knowledge of Drupal. Please visit http://groups.drupal.org/code-review for details on how to participate.

jpontani’s picture

Status: Needs review » Needs work

Quick review:
- README should be README.txt
- remove drupalkey and drupalkey.pub from your repo
- Add a line break after your version line in .info file
- Indentation should be done using 2 spaces per level, not tabs
- Remove your commented drupal_set_message lines
- Doxygen comment should be "Implements hook_node_presave()." Then if you need, add extra comment lines after if you need to describe in detail what exactly it does. You don't need the @param directive as that's documented on hook_node_presave.
- Replace 'und' with LANGUAGE_NONE (http://api.drupal.org/api/drupal/includes--bootstrap.inc/constant/LANGUA...)

Having an end user have to modify PHP code to get it working is not exactly what you want to start out with, as it's very easy to mess stuff up and WSOD a site, even with just a single missing semicolon.

Start with just the UI for customizing which fields are parent/child without having them be hardcoded.

misc’s picture

The applicant has been contacted to ask if the application is abandoned.

aristeides’s picture

This application for full project access is postponed because at the moment I don't have the time to deal with it.
However I wouldn't say it's "abandoned", the project that has been taking up most of my time will be finished in 1-2 months so at that point I'll get back to finishing this module.

misc’s picture

Status: Needs work » Postponed

See comment #4

pindaman’s picture

Tried the module.
Terms are being created as child/parent relation.. .. perfect BUT...

Is not comparible with taxonomy menu option:
Synchronise changes to this vocabulary

givens many errors.
If you can fix this please do...
may be a chipping, for your work?
thanks

klausi’s picture

Status: Postponed » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.