Closed (fixed)
Project:
Add Another
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
6 Nov 2012 at 16:36 UTC
Updated:
31 Jan 2017 at 18:03 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
danielfdsilva commentedI found out that this happens because the drupal_goto() function gives priority to the destination if it's set.
I fixed the problem by unsetting the destination but in our project we needed to be able to add multiple content while keeping the destination parameter for later use.
To accomplish this I modified the module creating a customizable option that allows us to keep the destination and other query params as well.
This option is content-type specific and it's not set by default cousing the destination parameter to be discarded.
This is my firt collaboration with the drupal comunity. If you have some comments or tips i'll appreciate.
Comment #2
danielfdsilva commentedComment #3
danielfdsilva commentedComment #4
sokrplare commentedWorks beautifully - saved me some time for a client project - thanks!
Only thing to tweak is switching to use double-spaces instead of tabs per Drupal Coding Standards. I've set this to RTBC though so it can get committed and hopefully something that minor can just be tweaked as it gets committed - or if you can resubmit with tabs switched to spaces that would be ideal!
Comment #5
robin monks commentedThis does look good; and thanks for the patch Daniel! That said, with something like this it needs a test added. For information on writing tests check out http://drupal.org/simpletest and the existing addanother.test file.
/Robin
Comment #6
danielfdsilva commentedI changed the tabs to double spaces like covenantd said.
As for the test, I had a quick look at the docs and it didn't seem easy. I need to read a bit more.
Anyway, here's the patch.
Comment #7
sokrplare commented@danielfdsilva - yeah, the test framework scares me too :)
I'm wondering if the code added to the
node_clone_onsave_node_form_submitfunctions should be moved into_node_clone_onsave_node_clone_pathso it will be picked up bytheme_node_clone_onsave_message_messageas well?As a sidenote, I've just spent an hour and ported this code pretty directly over into a node_clone_onsave module I'm putting in my sandbox (http://drupal.org/sandbox/covenantd/1866074) and either will add as a patch to the clone module (#1866082: Patch or standalone module for Node Clone on Save button), or as a standalone module.
Comment #8
koppie commentedUnfortunately the patch loses the destination url if you click "add another."
Comment #9
danielfdsilva commented@koppie
When configuring addanother, you have an option to keep the query params (last option).
Isn't that what you want? :)
Comment #10
nwom commentedIt works perfectly. The destination querystring works as well.
Thank you very much for the patch!
Comment #11
nwom commentedAh didn't realize the tests still had work. Changing the status again.
Also, just found out that the button works perfectly, however the "Display the Add another message after node creation. " does not include the query parameters.
Comment #12
lunk rat commentedThanks @danielfdsilva for the patch in #6! It works perfectly a destination URL is provided (as long as I configure the content type to preserve URL parameters)
Note: this patch is based on Drupal site root directory (it should be based on addanother module root directory).
Comment #13
pianomansam commentedPatch in #6 doesn't work when a $_GET param is an array. Is is an updated patch that uses Drupal's url() function to correctly pass along the $_GET params. Also note that this patch it to 7.x-2.2 as 7.x-2.x-dev has changed drastically.
Comment #14
david.qdoscc commented#13 works great for me. Thanks!
Comment #15
robin monks commentedChanged the logic as there really isn't a point to having a setting for telling Add Another to do the right thing, so now if there's a destination it's saved between adding nodes and enforced at the end. Also added tests for this. This will make its way into 2.x-dev, but is here for any input needed.
Comment #16
robin monks commentedThis has landed on 7.x-2.x.
Comment #19
marassa commented(sorry, never mind)
Comment #20
david.qdoscc commentedI think this issue needs reopening. #13 still behaves correctly for me, whereas #15 only kept the destination parameter, but dropped other query parameters (I am using multiple parameters to prepopulate fields, along with the destination parameter). Perhaps more testing is required?Sorry - just seen this is now a separate issue: #2850821: Query parameters apart from "destination" are removed when clicking "Add Another"