Reverse node reference
kelisfreek - July 25, 2007 - 03:26
So basically, I'm trying to display a list of nodes that references the current node.
I'm making each node about a person. I made node reference fields to enter in each persons mother and father. Now I want to display each person's children based on the mother/father fields.
I was able to get a list of the right nodes using a view to filter nodes based on the nodereference fields... but I have to select a specific parent node to get the list from. I want it to automatically get the right parent node from the current node...
I'm pretty new to drupal and I dont think I'm that good on explaining so sorry if this is confusing... Can anyone help?

Just thought I'd bump this
Just thought I'd bump this up to the top once more... can anyone help?
Yesss!
I finally figured out how to do this for my own site, after a couple of afternoons of gnashing of teeth.
I have nodes for games, and nodes for persons. The person nodes have node reference fields which refer to the game nodes. (I'm using this for people who want to register for games at a game convention. For various reasons I didn't want to use the signup module.)
I create a view with:
$args[0] = arg(1);(Thanks to a comment from Paul Resnick here)I go to the block administration page, activate the block, and choose that it should only be shown on the nodes that hold games.
And voila! At the bottom of my game page, there's a nice little list of all the people who have registered for that game.
Hmm, it occurs to me that it will be a lot of bother to specify where the block shall be displayed for all relevant pages. If I remember correctly, I've seen a module for CCK Viewfields which should automate this nicely. Or perhaps I'm better off with a PHP snippet...
* strolls over to the Handbook, happily whistling *
You are amazing. Thanks!
You are amazing. Thanks!
How do you add a node?
zirvap
How can you add a game on the "person add form"?
Is this possible?
Is there a way to add and reference at the same time?
Thanks for your help.
just gotta say
this code works perfect and zirvap you are a life saver!
multiple node reference arguments
How would you create a this views block that contains multiple node reference arguments?
TIA,
txcrew
Only one
The views blocks I made only had one node reference argument. I made several blocks with one node reference argument each. (Heh, that sounds cryptic even to myself. Tell me if you'd like a more detailed description.)
That was my last resort
In my case, I have about 11 Node Reference fields in my content type (see http://drupal.org/node/201815 for my scenario) and I was hoping there may be a better way to do it. Perhaps just editing that Argument Handling Code to accomdate for multiple for one or more of one of the arguments that are selected. But alas, I have very limited programming knowledge and from what I have been researching so far, it doesn't seem very possible.
Does your method have any impact on performance? Any more or less than having one view with several arguments?
Thanks for the reply!
txcrew
Don't know about performance
I have six node reference fields, which means it wasn't too much of a hassle to make a view for each. I haven't looked at performance at all. The scope of the site is pretty small (a yearly game convention with about 100-150 participants), so performance isn't much of an issue.
Strange views cache issue
UPDATE: Sorry, I figured out the issue myself, 2 of my db tables were out of sync.
THANK YOU VERY MUSH! It
THANK YOU VERY MUSH!
It works for me.
The sample website (Chinese):
http://www.buyerjoy.com/shop/761 and http://www.buyerjoy.com/brand/627 refers each other
--------------------
BUYERJOY
Yesss!
Deleting duplicate post.
Yes?
Yes it can be done? How would you do it?
CCK Nodereference
Use CCK to add a Node Reference field to the 'person' content type, then when you create 'person' content you'll be able to select an existing node to reference.
The problem is that you
The problem is that you can't add a person from the create game form or vice versa. You can only reference a record if it has already been created.
I sort of have the same problem here and here.
Maybe someone could help me out.
These are very relevant:
These are very relevant: http://drupal.org/node/60756 http://drupal.org/project/nodereferrer http://drupal.org/node/158287
Drupal 6
Anyone have it working on Drupal 6?
I would like to know how to
I would like to know how to do this on drupal 6 too?
thanks
Luis
I would like to know how to do this in drupal 6 too
Argument: Node Reference does not show as one of the options. Thanks
http://www.faunapolis.org/
How to reverse node reference in Drupal 6
I asked the CCK module developer, and he very promptly answered.
The newer development version has the solution, please see:
http://drupal.org/node/265958
the alpha version of CCK for D6 did not have the option incorporated yet
http://www.faunapolis.org/
Working!
Based on http://drupal.org/node/259845, finally got it working.
1. Created a relationship,
2. Argument Node:nid, using relationship,
3. Also had to use page/attachment type of view as blocks can not pass arguments, as far as I know,
4. Did other settings, like fields, filters, etc,
5. Used
<?phpprint views_embed_view(my_view_name, $display_id = 'attachment', arg(1));
?>
6. Worked!
Hope this helps someone.
Thanks!
I have been trying to figure out how to basically add the functionality of nodereferrer to Drupal 6 since the module has not been ported yet, and I would have no clue on how to help port it. After tons and tons of searching and fiddling I finally got exactly what I was looking for out of your method. I did not even create a block view, only an attachment since I had no need to have it displayed in a block.
Also just for reference, I was not sure where I was supposed to put the PHP code, but finally figured out that I had to create a .tpl.php file for the content type and add it using this method: http://drupal.org/node/17565
Thank you so much for this.
This may be the solution -> Nodereferrer field
Hey all,
I've been looking for what I think is the same thing, and recently, somebody created it!!! Check this post about the Nodereferrer field in Drupal 6!
Matherion