working-taxonomy
| Project: | Imagefield Import |
| Version: | 5.x-1.0-beta |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
I messed around with this module a little bit. I've attached a patch that got the taxonomy portion working for me. The problem with the current implementation of the taxonomy code is that we use the taxonomy_form_alter function with an incorrect form id of 'image_node_form'. This will only work if your node type is named "image" (as with the Image module). However, if your node type name is different (e.g. 'photo' in the attached patch), then you need to use a form id of 'nodetype_node_form'. I simply changed the form id to 'photo_node_form' for my case, and it worked. Also, you have to uncomment the portion of the submit function that handles taxonomy, as is done in the patch.
Since I hard coded my node type's name into the form id, we still need to abstract this out to include arbitrarily set node type names. This shouldn't be too difficult to do. I just haven't had time yet.
| Attachment | Size |
|---|---|
| imagefield_import.patch | 2.28 KB |

#1
I should mention that I'm not really certain how to create appropriate patches yet, and I wasn't totally clear with my first post. So here's the idea...There is code to include the taxonomy options on the upload page:
<?phpif ($files) {
if (module_exists('taxonomy')) {
// a little hack from the image_import.module to get the taxonmy controls onto our form---
$form['type'] = array('#type' => 'value', '#value' => 'image');
$form['#node'] = new stdClass();
$form['#node']->type = 'image';
//this form id must be changed to the appropriate node type_node_form
taxonomy_form_alter('image_node_form', $form);
unset($form['type']);
unset($form['#node']);
}
?>
There are three references here that assume your node type is named "image". This may not be the case, and should be abstracted to find the correct node type name, whether it's "image", "photo", etc. I changed them for my case to be "photo" (my node type name) and everything worked properly. Additionally, I believe that the code in the imagefield_create_node_from function for taxonomy must be uncommented for the selected term to be appropriately applied:
<?phpif (module_exists('taxonomy')) {
$node->taxonomy = $taxonomy;
}
?>
#2
I think that I now have the module fully functional for taxonomy, and it works with any node type name. Here's the portions of the imagefield_import_form() function that I changed. First, I get the node type name:
<?php//get the content type and field names
$targetsetting = variable_get('imagefield_import_fieldname', FALSE);
list($type, $field) = split(":::", $targetsetting);
?>
Then I fixed the taxonomy portion of the same function:
<?phpif (module_exists('taxonomy')) {
// a little hack from the image_import.module to get the taxonmy controls onto our form---
$form['type'] = array('#type' => 'value', '#value' => $type);
$form['#node'] = new stdClass();
$form['#node']->type = $type;
$form_id = $type . '_node_form';
taxonomy_form_alter($form_id, $form);
unset($form['type']);
unset($form['#node']);
}
?>
Then uncomment the taxonomy portion of the imagefield_create_node_from() function:
<?phpif (module_exists('taxonomy')) {
$node->taxonomy = $taxonomy;
}
?>
With these changes, my code is fully functional, as far as taxonomy is concerned.
#3
I took your e-mail and rolled a patch with the file-- Will apply and test in the morning.
Other tests encouraged! :-)
#4
Applied And tested. Thanks.
#5
Am I supposed to use Fixed, or closed?
Either way it's fixed.
#6
Automatically closed -- issue fixed for two weeks with no activity.