Hi

I've been using the module for a little while without problems, but have recently tried to change the behavior of the form where it's in use. My goal is to set a custom destination (using (domain.tld/node/add/photos?destination=xxx in the query-string) for when the form submits, but unfortunately this module breaks that (debugging showed that only when images are uploaded using the FUplad module the page redirection fails).

Is there any way to make this work with the FUpload module?

Best regards,
Thomas René Sidor

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nightowl77’s picture

Status: Active » Patch (to be ported)
FileSize
4.47 KB

Hi Thomas

I had the same problem. I use nodereference_url for a photo gallery system (as described in Jeff Eatons video) but wanted to add the additional functionally of image_fupload, which isn't covered in Jeff's video.

To make this work I used the one image per node option. But the client got terribly confused when he returned to the "node add" page - since noderefernce_url could not pick up the reference any more - causing all sorts of havoc.

I've submitted a patch that solves this problem. The patch does the following:

- on your image_fupload widget (in your manage fields area) you can now tick a checkbox that says
" Redirect to destination sent by system/other modules "

- It will then redirect the user back to whatever the destination was. This is great because noderefernce_url has 3 options of it's own (also along the lines of - return to node created, return to referened node, etc, etc). The 2 modules, and possibly other modules, now play along nicely.

- The patch doesn't interfere with existing options - if you don't select that tickbox "if statements" will make sure everything works like it did before. Even if you select the tickbox and you had a "Redirect URL" configured, the original "redirect URL" will take preference.

Note: Not tested for these scenarios:

- I didn't test redirection on multiple-images-per-node galleries. Sorry guys - this project was supposed to be finished yesterday and had to start with the next one... well... yesterday. It is my hope that this patch will give a good starting point, most of the grunt work and figuring out is already done, someone must just add a line or 2 of code where the multiple-images-per-node executes

- I didn't test this where the user doesn't have access rights to "edit captions". When "edit captions" is off I get an error saying that there are "no images uploaded" when in fact there are images. At first I thought I broke something but checked out the HEAD from cvs and it still happens. Will investigate later and submit a bug report if the problem isn't purely on my side.

This patch was against the HEAD code as of 25 Nov 2009. Your feedback would be appreciated.

hadsie’s picture

Thanks for that patch @nightowl77. One suggestion though, the code in image_fupload_imagefield.module might be a bit cleaner if you used drupal_get_destination() and the options parameter of url() like so:

$redirect_url = '';
$options = array();
if ($field['widget']['fupload_honor_destination'] && $_REQUEST['destination']) {
  $options['query'] = drupal_get_destination();
}
if (user_access('edit captions')) {
  $redirect_url = url('node/add/'. str_replace("_", "-", $node_type) .'/list_imagefields', $options);
}
sinuz’s picture

@1, just tested your patch and it works really well! Thanks for that.
Maybe this patch can be combined with the #527618: custom redirection after multiple node creation using tokens patch?

grandcat’s picture

Status: Patch (to be ported) » Needs work

@hadsie:

Would be great if you can create a new patch which includes all changes compared to CVS HEAD version.

hadsie’s picture

Status: Needs work » Needs review
FileSize
4.55 KB

I've attached a patch against HEAD with the mentioned change.

webadpro’s picture

I'm just wondering if this feature has been added to the dev version because it doesn't seem to be in the 6.x-3.0-rc2 version.

Thanks

ankerek’s picture

@5 It works! Thank you