Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
What if you wanted to "single source" 1 image node so that it could be referenced from lets say 3 or 4 image gallery nodes. Right now it seems that all you can do is upload 1 image at a time. Is there anyway that "Add an image" node reference URL could also allow you to associate a pre-existing node? And I apologize if I'm asking for something ridiculously complicated.
Comment | File | Size | Author |
---|---|---|---|
#27 | nodereference_url_428988_27_multivalue_field.patch | 1.47 KB | johnv |
#28 | nodereference_url_428988_28_multivalue_field.patch | 886 bytes | johnv |
#8 | nodereference_url-428988.patch | 9.11 KB | hefox |
Comments
Comment #1
quicksketchWe'd probably need to support #396818: Ability to change values when editing also in order to support this properly, since right now once a value is set it's impossible to change and we'd probably need a way to remove references.
The biggest obstacle in this task is figuring out how to reference an existing node. I imagine we'd need to make a second link entirely so you'd have the links "Add a new [type]" and "Add an existing [type]" links. The "Add an existing [type]" link would need to go to a page that lets you select an existing node, probably just in a single field form:
The Node Reference field type would be configurable, so you can choose either an autocomplete or select list for this form. It'd definitely still be an improvement over the current workflow of needing to find the original node, then updating the node reference field by editing the node, but it's a lot of work and perhaps only loosely related to this module's original intention. So I'll ask the question, is it worth implementing and should it be implemented in this module?
Comment #2
rgme CreditAttribution: rgme commentedI vote for the ability to at least set the number of values allowed. I'm trying to use the Node Reference Formatters module to mirror node references back and forth. That module requires the "number of values" to be set at unlimited. That option is missing from the node reference url widget.
Is there a way to just allow that option (even though I probably won't use more that one)? Does simply having the option break things, or does using the option (i.e., more than one node referenced) break them?
EDIT: I commented out line 26:
$form['field']['multiple']['#type'] = 'value';
and it seems to work well. Can you forewarn me of any problems I might have with this?
Comment #3
quicksketchThe links generated by Node Reference URL widget will only work for the first value. I'm not sure of other consequences you might have with such an approach.
Comment #4
rgme CreditAttribution: rgme commentedCool. It seems to working for me.
Comment #5
quicksketchMarked #635262: multiple nids in url as duplicate.
Comment #6
hefox CreditAttribution: hefox commentedsubscribe
--
hefox: btw quick sketch, have ya ever considered splitting node refer url into two widgets, one for multi fields (select, radios, etc.) one for single (autocomplete), with the purpsoe o mutli ?
hefox: Two widgets instead of one, with one widget being cck handle multi, one being module handle multi
hefox: autocomplete == cck handle multi, then letting it be multi, with first value being the url one
quicksketch: hefox: oh i gotcha i think. basically if you went to node/add/[type]/[nid] it would prepopulate the first field but allow you to add another node reference if it was a multi-value field?
Comment #7
quicksketchI like hefox's idea (pulled from #drupal IRC logs). Right now Node Reference URL explicitly turns off multi-value handling. This would make it so that Node Reference URL Widget would pre-populate the first reference and then allow the user to enter more references (using the fallback widget) if the field were configured to allow multiple values.
Comment #8
hefox CreditAttribution: hefox commentedInitial patch.
Creates the separate widgets.
Need an update hook to change settings of existing settings for those using nodereference_url (may just want to switch em over to using select if autocomplete and nodereference_url, as that is also an issue when switching between widgets).
Have tested multi/single select/autocomplete. May want additional settings for it also, wasn't sure what to do in some circumstances.
(Edit: 2 things that I would like to get in, but prefer waiting for the above patch to flash out, is fallback checkboxes and display link for other build modes than just teaser/full; I use build modes defined via hook_content_build_modes for display of featured content, etc. Leaving it here as a reminder).
Comment #9
scottrouse CreditAttribution: scottrouse commentedThe patch referenced in #8 worked perfectly for me. I'm running a fairly clean install.
Happy to answer any questions which may help. I recommend pushing this patch to the dev build.
Comment #10
mastoll CreditAttribution: mastoll commentedWill this happen any time soon? What is required for the patch to move into the dev build?
Comment #11
mastoll CreditAttribution: mastoll commentedJust checking in. This was a fast-paced conversation and all of a sudden it stopped. What does it take to move the patch to the dev build? As far as I can see, the Nodereference URL Widge module doesn't have a .dev option.
--MAS
Comment #12
mastoll CreditAttribution: mastoll commentedI applied the patch in #8 and it appears to work fine for new nodes.
For existing nodes, I'm interested in the update hook to change the settings of existing nodes built on the non-patched Nodereference URL Widget.
Comment #13
hefox CreditAttribution: hefox commentedTo be brief, the actual nodes itself do not need to be changed if i remember correctly, but field settings of existing sites likely need an update hook. Unfortunately I do not have time for that ATM.
Comment #14
scottrouse CreditAttribution: scottrouse commentedStrange. It seems that if I change the Widget type for the field in question from Reference from URL to something like Select list, save those changes, configure the select list widget type to allow multiple/unlimited values, save it, then go back and change the widget type back to Reference from URL, I get the desired functionality.
Desired functionality = user clicks the link on a node (foo) to create a new node (bar) referencing foo. User can then edit bar and is able to select nodes in addition to foo as a reference.
-Scott
Comment #15
mastoll CreditAttribution: mastoll commentedStrange, Scott. And that was without adding the patch?
Comment #16
webwriter CreditAttribution: webwriter commentedI tried it without adding the patch as described in #14 and didn't get it to work. Also couldn't get the patch to work- I keep getting "illegal operation detected" errors when I try alter an existing field to use the new widgets.
But that might possibly be because I have to patch manually on my stupid Nginx system and it's possible I mucked up the patch. I will try again tomorrow with a fresh attempt at the patch.
Comment #17
scottrouse CreditAttribution: scottrouse commentedYes, that would have been without the patch, I believe.
Comment #18
JGonzalez CreditAttribution: JGonzalez commentedI can confirm that without the patch, I get the desired functionality by first configuring select list with unlimited values, and then changing the widget to noderef_url as in #14
Comment #19
etomilin CreditAttribution: etomilin commentedPatch #8 worked fine for me.
Comment #20
Exploratus CreditAttribution: Exploratus commentedsubscribe!!!!!! This was a huge drawback to the module, glad it is being addressed!
Comment #21
Makku01 CreditAttribution: Makku01 commentedsubscribe - #14 worked for me as well
Comment #22
zdean CreditAttribution: zdean commentedsubscribe
Comment #23
darora CreditAttribution: darora commentedsubscribe
Comment #24
bmnic CreditAttribution: bmnic commentedsubscribing
Comment #25
YK85 CreditAttribution: YK85 commented+1 subscribing
Comment #26
amalaer CreditAttribution: amalaer commentedsubscribing
Comment #27
johnvquicksketch, I have the impression that you implemented (part of) patch #8 in your latest release 1.8.
Also, you can have more multi-value cases then I expected, so I wrap it up:
With the current version 7.x-1.8:
1- I can choose between select and autocomplete, so I am not sure if #8 still applies?
2- I can create from single-value arguments, e.g. http://www.example.com/node/add/my_node/73577
3- I can use multiple arguments to fill multiple fields, according to #362468: Populate multiple fields through the URL.
4- I cannot use a multiple-value field together with nodereference_url.
5- I cannot create from multi-value arguments, e.g. http://www.example.com/node/add/my_node/73577,73578
I have created attached patch for case 4; please feel free to add case 5. There must be a standard method to split multiple-value arg's, but I do not know of one...
There is still an issue when you want to add more values on the create/add page - the initial reference gets lost. But it works if you first save, then edit.
Comment #28
johnvSome remarks upon my patch #27:
- It removed the D6-function nodereference_url_form_alter(), which I shouldn't have. I attached a new patch.
- I didn't test D6, you might want to remove line 25: $form['field']['multiple']['#type'] = 'value';
Comment #29
ylavi CreditAttribution: ylavi commentedI have the latest version 1.8 installed on Drupal 6. The initial sign of trouble for me was the inability to add a comment to a node with an unlimited-value field configured with auto-complete fallback (I have comment-driven set up).
Automatic patching failed due to a difference between the installed file and what the patch expected so I tried, unsuccessfully, to install the patch manually.
I gave up on the patch after finding at some point that the select list widget fallback does work OK with multiple value fields - the problem appears to be with the auto-complete fallback widget.
Comment #30
johnvylavi, the patch is created for D7, so it's likey to give you some problems applying. Good that you don't need the patch after all. :-)
Comment #31
quicksketch@johnv:
No I have not implemented any of this issue. If I had, I would update this issue. I don't think your patches are correct for this issue, but they do fix other problems. I implemented a very similar solution to your suggestions in #1119874: If a content type has a field with an unlimited number of values, you lose the node reference when you save., so you can consider the patches in #28 and #29 as applied. They do not have any effect on multi-value handling though, in D6 or D7. I'm taking a look at this issue currently, but it's not looking too good so far. In D7, we don't force users to use a single-value field, but the multi-value field doesn't work if you try to use it (which makes me think we should force single-value at least until it does work).
Comment #32
quicksketchWell I know no one wants hear that I've disabled multivalue handling in D7, but as johnv reported in #27, multivalue fields did not work with Node Reference URL Widget in Drupal 7 either, so I've disabled the option to match D6 as posted in #1138356: Disable multivalue handling in D7 until implemented correctly.
I've reviewed hefox's #8 and it doesn't look acceptable for a variety of reasons (code style, fixes issues not related to this one, and just an odd approach generally speaking). Unfortunately just changing the number of options to a higher value does not work in D7 (even if it works in D6). We'll need solutions for both.
Comment #33
brunorios1 CreditAttribution: brunorios1 commentedsubscribing...
Comment #34
brunorios1 CreditAttribution: brunorios1 commentedi'm using the 6.x.-1.10 version...
i'm using the "Extra node reference widget features" of the "Node Relationships" module, that shows a "+" button that allows me to create a new node and references it "on the fly"... but this widget only works in nodereference Autocomplete widgets...
so i can't use this feature with the Select List in Nodereference URL Widget Fallback behaviour...
would be perfect that the nodereference url autocomplete widget works with multiple values in the fallback, showing multiple autocomplete fields instead of a select list.
would be possible???
thanks!!!
Comment #35
sk33lz CreditAttribution: sk33lz commentedSubscribing.
I just ran into this issue using D6 and the Views Gallery module that KarenS made from the Feature that Eaton and Crell made for the SXSW CMS Showdown. It was quite a lean and mean gallery solution until I hit that wall. Some photos just need to be in multiple categories on a well categorized gallery site. Uploading them again to another gallery is not really a viable option, as it is time consuming and a waste of hard drive space. I hope to find a solution by following this thread.
Comment #36
vasikesubscribe. i agree with #428988-27: Multiple reference handling points
i think for the 4 and 5 points it's good to have also some displaying options. please check #1216478: Display Fields of the Node Reference
Comment #37
BeaPower CreditAttribution: BeaPower commentedsub
Comment #38
tribe_of_dan CreditAttribution: tribe_of_dan commentedsub
Comment #39
facal CreditAttribution: facal commentedsubscribing
Comment #40
JustMagicMaria CreditAttribution: JustMagicMaria commentedAny progress on this? Like sk33lz in #35, I have a real use case for this and think this is an important feature.
Comment #41
iantresman CreditAttribution: iantresman commentedBeing able to select multiple nodes references is very useful!
Comment #42
rickharington CreditAttribution: rickharington commentedCan confirm that #14 worked.