Attached file should be renamed nodereference.inc and included in the ./relationships/ directory.
This seemed like such an obvious relationship, and CCK seems popular enough (and I needed it :-), that I think it makes sense to include in main Panels module.

CommentFileSizeAuthor
#2 nodereference.txt1.71 KBschuyler1d
nodereference.txt1.7 KBschuyler1d

Comments

sdboyer’s picture

Project: Panels » Content Construction Kit (CCK)
Version: 5.x-2.x-dev » 5.x-1.x-dev
Component: Plugins - relationships » nodereference.module
Status: Needs review » Needs work

Great! Thanks for this, only a handful of people are actually writing new plugins, and I hadn't yet had the time to get around to this one.

Unfortunately, though, I'm not going to commit it. It doesn't make sense to include it directly in Panels, quite simply because of the if statement that appears on line 10 - it should be implemented by nodereference itself. So I'm booting this over to CCK.

Also, three things, two nitpicky and one more serious.

1. Don't abbreviate unnecessarily - in other words, $fname should be $field_name.
2. It may just be a typo, but Drupal coding standards dictate that there's no space after the first paren in a foreach - so foreach ( content_fields() should be foreach (content_fields().

3. More serious - As it operates right now, this would appear on ALL forms with a node context, with no knowledge of whether or not a nodereference field actually exists for the node that's being passed through. There's no way of knowing in beta5, but gordon has recently been working on some improvements to the node context that allows specification of node type - and basically, I'd really rather see this smart enough to be able to take advantage of the typed node context information when it's available. Really doing so properly won't be available for a little while yet, I don't think, but I think it's an important goal to keep in mind.

We also might have to rejigger the Panels API a bit to give you the full flexibility you'd need for to accomplish such a thing, but I'd be willing for plugin.

schuyler1d’s picture

StatusFileSize
new1.71 KB

@1, WRT '3. More serious', I took a preliminary look at what might be involved to make this possible. The least would be:
3.1 panels_[[relationship]]_settings_form($conf) needs a second argument ($conf, $context)
3.2 Choosing a different context in the add/edit relationship form needs an ajax-form refresh
3.3 Getting the node type into $context for nid, node-edit, node-add (btw, is there a reason why node-edit/node-add are different arguments rather than 'content types'?)
If I could see where gordon's going with 3.3 (either after a commit, or a link to a current patch? or an email?) I'd be willing to help with 3.1 and maybe 3.2.

This upload corrects the minor style issues, though for CCK, we'd obviously also get rid of the module_exists('nodereference') test, put the file in a panels_relationships/ directory, and then make a function with something like:

nodereference_panels_include_directory($plugintype) {
  switch($plugintype) {
   case 'relationships': return 'panels_relationships';
  }
}
karens’s picture

Status: Needs work » Closed (won't fix)

A very old feature request for D5, won't do anything with this now. This is possible in D6 now with Views 2.