Nodereference : Views-mode broken
| Project: | Content Construction Kit (CCK) |
| Version: | 6.x-2.x-dev |
| Component: | nodereference.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | fixed |
Hello everybody,
I created a nodereference field and now I am trying to display only nodes that were created by the authenticated user. I installed Views and created a view for that. It is working great, from the views perspective. The problem is that Drupal is showing an error message saying "Notice: Undefined index" when I access node/add/[new-cck-node-type]. It points to the line 720 in nodereference.module; that is within theme_nodereference_item_advanced().
I've changed my php.ini to:
error_reporting = "E_ALL ^ E_NOTICE"
And they are gone now, but I think this is not only a matter of the level of PHP error reporting.. there is something weird happening. I'm saying that because the select for the nodereference field is showing something like:
9999 - Node title
9991 - Another Node title
9992 - Another Node title againWhen the views I created has only Node: Title on the Fields settings.
Why is CCK showing nids as well? Is there any way to clean this?
What about all those PHP error messages?
Thank you,
Andre

#1
Yes, the 'advanced mode / Views-defined referenceable nodes' is currently broken. This part of the code was adapted from CCK D5 to match the new Views 2 API some time ago, and Views has been moving since then.
I'm currently refactoring this area to rely on Views 2 notions of 'display plugin'. Stay tuned.
#2
Side note : meanwhile, and with the PHP warnings and display issues you mentioned, node submission still works and the nodereference field saves correctly.
#3
It's broken again? I've fixed it several times :-( It's pretty hard to keep up with Views sometimes, not that it hasn't been more than worth the trouble :-)
#4
Thank you very much, Yves. I'm sure this integration could look amazing.
Let me know once you're ready and count on me for testing.
[]s
#5
@avorio : I'm afraid you won't see much difference from the outside :-)
#6
Fixed. Still a few todos, but the thing works.
This uses dedicated views display and style plugins to have the view return a PHP array of results. Parts of this could be rolled into a later patch for Views, since this can be a common use. For now it lives in nodereference.module (which has its own specific needs anyway).
User-facing results of this patch are that admins have a few more possibilities to tweak the content of their select widgets or autocomplete results using Views 2 display options goodies.
#7
Yched,
Thanks for this great addition ! I've been doing quite a bit with it. I did run into one situation that shows up when doing Select lists from views with output that has single quotes in them. (they appear as ' ) I believe this is because check_plain() actually encodes them specifically:
<?phpfunction check_plain($text) {
return drupal_validate_utf8($text) ? htmlspecialchars($text, ENT_QUOTES) : '';
}
?>
So attached is a patch that adds them in for decoding...
#8
Have update the fix above and re-posted the patch to a new issue. Moving this back to fixed.