Well i'm with a little trouble sorting the way to see the related nodecomment father when i'm viewing the nodecomment itself as a node.

If i'm in the node father page, all the related comments appear below, but if i'm seeing the comment node there is no relationship visible to the node father.

How can this be achieved?

The only option i see, is adding a nodereference field to the nodeccomment referencing is father. But this solutions dosnt look very clean...

Thanks in advance

Comments

cratos’s picture

Ok i solved my problem. Used nodereference field with PHP code to get by default the respective node father.

here is the code:

$refnid = arg(1); 

if (is_numeric($refnid)) {
  return array( 0 => array('nid' => $refnid));
} else {
  return array( 0 => array('nid'));
}

Hope it helps someone;)

sirkitree’s picture

If you do a node_load of any given nodecomment, you'll find a $node->pid which is the parent id. This may be another nodecomment (for threading). There is also a comment_target_nid which always holds the original parent node id.

nid1
- nid2
- - nid3
- nid4

In the above example, a node_load on 3 would have a pid of 2 and a comment_target_nid of 1.

So if you wanted to create a link on any given node to the comment_target_nid you could create a variable in your template.php that would check for this variable and display a link to the comment_target_nid (or the pid, whichever you prefer).

cratos’s picture

That was really usefull information. Thanks for sharing your knowledge Sirkitree.

Not sure if i will adopt it in this issue, but will certainly be very usefull in near future.

Thanks

lastcowboy’s picture

hi cratos,

can you give me more details as to how your way works? i am new to drupal and know a little about php.

I am looking to have the nodecomment be able to display the link of the parent node when viewing the comment as a node by itself.

Please advise.

I am very interested to learn more.

thank you.

crea’s picture

Status: Active » Closed (fixed)

Closing all issues. Please reopen if still relevant with Node Comments 6.x - 2.x