You are here

function node_reference_preprocess_node in References 7.2

Theme preprocess function.

Allows specific node templates for nodes displayed as values of a node_reference field with a specific view mode.

File

node_reference/node_reference.module, line 1033
Defines a field type for referencing one node from another.

Code

function node_reference_preprocess_node(&$vars) {

  // The 'referencing_field' attribute of the node is added by the
  // node_reference_node mode formatter (display referenced node
  // in a specific view mode).
  if (!empty($vars['node']->referencing_field)) {
    $node = $vars['node'];
    $field_name = $node->referencing_field;
    $vars['theme_hook_suggestions'][] = 'node__node_reference';
    $vars['theme_hook_suggestions'][] = 'node__node_reference__' . $field_name;
    $vars['theme_hook_suggestions'][] = 'node__node_reference__' . $node->type;
    $vars['theme_hook_suggestions'][] = 'node__node_reference__' . $field_name . '__' . $node->type;
  }
}