Hello - I'm a co-maintainer of the Node Gallery module. I'm neck deep in a refactor for our 3.x release, and needed to come up with a way to do bulk imports in our module. Your module looked like it fit the bill, and boy, did it ever.

A very simple 3 line modification was all that I had to do to your module, and one hook_form_FORM_ID_alter() in node_gallery was all that was needed to integrate the two.

The attached patch simply checks if the node_gallery module is enabled, and if so, pulls the gallery id off of the form values and adds it to the node just before saving.

Now, I have a tab named 'import' when viewing a gallery that when clicked will show your form, but will create the relationship between the image and it's gallery.

I would love it if you can commit my patch (or rework the code so it works otherwise). Let me know if there's anything I can do.

CommentFileSizeAuthor
imagefield_import_node_gallery.patch757 bytesjustintime

Comments

kmonty’s picture

Subscribe

wulff’s picture

Assigned: Unassigned » wulff

Looks good! I'll include this change in the next release of the module. (Which will happen in the beginning of March.)

justintime’s picture

Just some thinking out loud:

While this certainly works well for my module, it's not a very efficient patch in that every other module that wants to do the same thing will need it's own little "if" statement in a patch to your module.

Since hook_form_FORM_ID_alter() lets any module modify the data that eventually gets put into $form_state_values, it might be wise to do something like this (untested code):

if (!empty($form_state_values['gid'])) {
  foreach (array_keys($form_state_values) as $key) {
    if (! isset($node->$key)) {
      $node->$key = $form_state_values[$key];
    }
  }
}

That way, the data is placed on the node, and the outside module's nodeapi save function can handle it from there.

Thoughts?

wulff’s picture

Status: Active » Fixed

This has been fixed in version 1.9.

I have basically implemented the solution you suggested in #3.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

crea’s picture

Component: Code » Documentation
Status: Closed (fixed) » Active

Oh, ignore me. I thought this code had something to do with plupload.

crea’s picture

Component: Documentation » Code
Status: Active » Closed (fixed)
crea’s picture

This issue was referenced in the plupload module code. Very confusing