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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

We'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:

Add an existing [type]:

Widget Label:
[ node list | v ]

[ Save ]

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?

rgme’s picture

I 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?

quicksketch’s picture

Can you forewarn me of any problems I might have with this?

The 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.

rgme’s picture

Cool. It seems to working for me.

quicksketch’s picture

Marked #635262: multiple nids in url as duplicate.

hefox’s picture

subscribe

--

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?

quicksketch’s picture

I 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.

hefox’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Status: Active » Needs review
FileSize
9.11 KB

Initial 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).

scottrouse’s picture

The 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.

mastoll’s picture

Will this happen any time soon? What is required for the patch to move into the dev build?

mastoll’s picture

Just 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

mastoll’s picture

I 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.

hefox’s picture

To 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.

scottrouse’s picture

Strange. 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

mastoll’s picture

Strange, Scott. And that was without adding the patch?

webwriter’s picture

I 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.

scottrouse’s picture

Yes, that would have been without the patch, I believe.

JGonzalez’s picture

I 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

etomilin’s picture

Patch #8 worked fine for me.

Exploratus’s picture

subscribe!!!!!! This was a huge drawback to the module, glad it is being addressed!

Makku01’s picture

subscribe - #14 worked for me as well

zdean’s picture

subscribe

darora’s picture

subscribe

bmnic’s picture

subscribing

YK85’s picture

+1 subscribing

amalaer’s picture

subscribing

johnv’s picture

quicksketch, 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.

johnv’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
FileSize
886 bytes

Some 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';

ylavi’s picture

I 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.

johnv’s picture

ylavi, 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. :-)

quicksketch’s picture

@johnv:

quicksketch, I have the impression that you implemented (part of) patch #8 in your latest release 1.8

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).

quicksketch’s picture

Status: Needs review » Needs work

Well 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.

brunorios1’s picture

subscribing...

brunorios1’s picture

i'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!!!

sk33lz’s picture

Subscribing.

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.

vasike’s picture

subscribe. 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

BeaPower’s picture

sub

tribe_of_dan’s picture

sub

facal’s picture

subscribing

JustMagicMaria’s picture

Any progress on this? Like sk33lz in #35, I have a real use case for this and think this is an important feature.

iantresman’s picture

Being able to select multiple nodes references is very useful!

  1. One option is to have the Node Reference URL Widget to piggy-back on one of the other widgets, and merely add the referring URL to those (if any) already added, with option to cancel and go back. For example:
    • If the Checkboxes/Radio buttons widget were selected, I would expect the Node Reference URL Widget to either (a) Add the referring URL to the list of items with the checkbox checked (b) or similar with the new radio button selected.
    • Or if the "Autocomplete text fields" were selected, I'd expect the referring URL's not to be added automatically.
  2. The other option is for the Node Reference URL Widget to allow the user to select whether multiple nodes are displayed as either checkboxes or Text fields, and recreate them
rickharington’s picture

Issue summary: View changes

Can confirm that #14 worked.