Starting on line 1714, we've got:

// only show link to attach existing node when the potential child doesn't require a parent.
      if ((!relativity_requires_parent($type) || relativity_multi_parent($type)) && node_access('update', $parent)) {
        $items[] = l(t('Attach existing !type', array('!type' => $type_name)), "relativity/listnodes/$type/parent/$parent_nid", array('class' => 'relativity_attach_'. $type));
      }

Which creates a link in the 'Edit relationships block' for attaching an existing node as a parent. This link brings up the list of possible parents for the node.

I'm looking to add another link directly after this which will allow me to attach an existing node as a child, bringing me to a page of possible children for the node.

I really don't know what I'm doing, and this is the first module I've actually tried to edit, but so far I've come up with the last line shown here:

      if ((!relativity_requires_parent($type) || relativity_multi_parent($type)) && node_access('update', $parent)) {
        $items[] = l(t('Attach existing !type', array('!type' => $type_name)), "relativity/listnodes/$type/parent/$parent_nid", array('class' => 'relativity_attach_'. $type));
      }
        $items[] = l(t('Attach existing !type', array('!type' => $type_name)), "relativity/listnodes/$type/child/$parent_nid", array('class' => 'relativity_attach_'. $type));

It does add another item to the edit relationships menu, but the page it links to does not exist..

All I did was copy the item and change "parent" to "child" in the url. I assume I am missing a large detail here.. Any advice?

Comments

chien_fu’s picture

Title: Looking to "Attach existing Parent" AND/OR "...child" » Looking to "Attach existing Child" AS WELL AS "Attach existing Parent"
tbenice’s picture

Huh, Chien_Fu, I think that you have it backwards. The module currently allows you to attach a CHILD node from a node's view page. That's what the link:

l(t('Attach existing !type', array('!type' => $type_name)), "relativity/listnodes/$type/parent/$parent_nid", array('class' => 'relativity_attach_'. $type))

will do.

Good idea here to have the ability to either link a node to a CHILD or a PARENT. You're on the right track but need to some code to make it work.

On the other hand, this functionality is one of the things my patch does (http://drupal.org/node/350778) so you might consider chiming in to get it tested and maybe included in a new version.

regards!

tbenice’s picture

Title: Looking to "Attach existing Child" AS WELL AS "Attach existing Parent" » Looking to "Attach existing Parent" AS WELL AS "Attach existing Child"
Version: 6.x-1.3 » 6.x-1.x-dev
Category: task » feature
Status: Active » Needs review
StatusFileSize
new17.12 KB

Here's a patch that accomplishes this. Be sure to rebuild menus as I changed them a bit to accommodate attaching either child or parent. I used the 'add child relations' perm to allow also adding an existing parent.