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 again

When 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

CommentFileSizeAuthor
#7 cck-nodereference-quotes.patch617 bytesMoonshine
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Title: Nodereference items coming from views » Nodereference : Views-mode broken
Version: 6.x-2.0-rc3 » 6.x-2.x-dev
Category: support » bug
Priority: Normal » Critical

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.

yched’s picture

Side note : meanwhile, and with the PHP warnings and display issues you mentioned, node submission still works and the nodereference field saves correctly.

KarenS’s picture

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

avorio’s picture

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

yched’s picture

@avorio : I'm afraid you won't see much difference from the outside :-)

yched’s picture

Status: Active » Fixed

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.

Moonshine’s picture

Priority: Critical » Normal
Status: Fixed » Needs review
FileSize
617 bytes

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:

function check_plain($text) {
  return drupal_validate_utf8($text) ? htmlspecialchars($text, ENT_QUOTES) : '';
}

So attached is a patch that adds them in for decoding...

Moonshine’s picture

Status: Needs review » Fixed

Have update the fix above and re-posted the patch to a new issue. Moving this back to fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.