0
votes

I am in a node, I created a field using "References" module to relate one content type to another. Now... The 2 content type are "PRACTISE" (a node with title, description ecc...) and "TECHNOLOGY", a node with just logo images. I want to show related logo into node--practise.tpl.php. How can i do this in DP7?

1

1 Answers

0
votes

I wouldn't do it directly in the template file, instead you'd be better off implementing hook_preprocess_node in your theme's template.php file to pass the logo(s) in as a variable. The logic is the same either way:

function mytheme_preprocess_node(&$vars) {
  $node = $vars['node'];

  if ($node->type == 'practise') {
    $related_node_nid = $node->field_related_field_name['und'][0]['nid'];
    $related_node = node_load($related_node_nid);

    $logos = '';
    foreach ($related_node->field_logo_field_name['und'] as $img) {
      $logos .= theme('image', array('path' => $img['uri'], 'alt' => 'Alt text'));
    }
    $vars['related_logos'] = $logos;
  }
}

Then in your template.php file you will have the variable $logos which will contain the list of logos you built up in the preprocess function. Obviously you can tailer the HTML to suit your needs, and you need to swap in the correct field names for field_related_field_name and field_logo_field_name.