Hello,

I'm using Content template module and I'm looking to use a node reference:

node-type A: field_xxx

node-type B: node reference A

Content template node-type B:

print $node->field_xxx[0]['view'] but how to use the node reference in it??

I don't know if I need this module or If I can do it without it.

Thanks :)

Comments

greg.harvey’s picture

Project: Node Reference Variables » Content Templates (Contemplate)

I don't know either, since I've never used content templates before. Sorry. I suggest you move this over there.

junro’s picture

Title: Node Reference Variables module is what I'm looking for?? » Using node reference in content template
junro’s picture

node-type A: field_title_france

node-type B: node reference A, the node referrence cck fielk name is: field_lien_fiche

Content template node-type B:

print $node->field_title_france[0]['view'] 

but how to use the node reference in it?? (field_title_france is a cck from node A)

I try:


$noderefnode = node_load($nid);
print $noderefnode->field_titre_france[0]['value'];

Any ideas? :)

jrglasgow’s picture

I guess I really don't know what you are trying to do with this node reference field in contemplate...

really the only advice I can give you is, assuming your node reference field name is field_node_reference:

<?php
$referenced_node = node_load($node->field_node_reference[0]['nid']);

// I don't have a node in front of me with a node reference field, 
// but I believe that this should be right now you have 2 node objects

print $node->title; // is the original referencing node
print $referenced_node->title;  // is the referenced node
?>
junro’s picture

Status: Active » Fixed

That's work with that code: :)

$noderefnode = node_load($field_lien_fiche[0][nid]);
print $noderefnode->field_title_france[0]['value'];

Thanks for your help ^^

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.