Reputation: 1310
I have a new content type called 'A' which has a cck reference node field that makes reference to type 'B'.
I have a custom template that renders out all node types 'B' in a very specific way.. the problem is that for this template, I need to know who the current node belongs to.
type B will always have a parent (of type 'A').. but I have no way to know the nid of the parent.
Is this possible?
So in short, when $node->type == 'B' print $node->parent->nid???????????? how can this be done?
Upvotes: 1
Views: 856
Reputation: 5015
Old Solution: Try using the http://drupal.org/project/cnr (Corresponding Node References) Module. This way you will be able to find out the "parent" of Node B. Basically you will get a node reference field in Node of type B that points back to a Node of type A (the "parent" node). Also you will only need to update one of the Node Reference fields -- the other will be kept in sync automatically.
Alternate and Better Solution
Try using the Node Referer Module. See http://drupal.org/node/431308
Upvotes: 1