Hi, the theme_hook_suggestions in "node_reference_preprocess_node(&$vars)"

$vars['theme_hook_suggestions'][] = 'node-reference';
$vars['theme_hook_suggestions'][] = 'node-reference__' . $field['field_name'];
$vars['theme_hook_suggestions'][] = 'node-reference__' . $node->type;
$vars['theme_hook_suggestions'][] = 'node-reference__' . $field['field_name'] . '__' . $node->type;

don't redirect to templates with names like theme/.../node-reference.tpl.php or other ...

I change it to

$vars['theme_hook_suggestions'][] = 'node__nodereference';
$vars['theme_hook_suggestions'][] = 'node__nodereference__' . $field['field_name'];
$vars['theme_hook_suggestions'][] = 'node__nodereference__' . $node->type;
$vars['theme_hook_suggestions'][] = 'node__nodereference__' . $field['field_name'] . '__' . $node->type;

and then it works with filenames like node--nodereference.tpl.php.

Robert

CommentFileSizeAuthor
#2 node_reference-985370-2.patch1.09 KBmatason

Comments

cezaryrk’s picture

Update,

the value of $field = $node->referencing_field; is the fieldname, so i changed $field['field_name'] to $field, now it works fine

$vars['theme_hook_suggestions'][] = 'node__nodereference';
$vars['theme_hook_suggestions'][] = 'node__nodereference__' . $field;
$vars['theme_hook_suggestions'][] = 'node__nodereference__' . $node->type;
$vars['theme_hook_suggestions'][] = 'node__nodereference__' . $field . '__' . $node->type;
matason’s picture

Status: Active » Needs review
StatusFileSize
new1.09 KB

I came across the very same issue, the attached patch fixes this for me.

cezaryrk’s picture

Thanks

yched’s picture