I'm writing a Drupal 7 application that has many content types. Each of these content types has a custom template for display. For instance, I have node--event.tpl.php, node--person.tpl.php, node--feedback.tpl.php, and so on.

I'd like to be able to manually call a theme function on a node that should have an overriding template. i.e. something like the following:

<?php print theme('node', array('node' => $node)); ?>

The reason for this is that I've written a module called Content Inclusion which allows pieces of content to be manually included within one another. I'm trying to have this line of code in my node.tpl.php file to automatically display the included node along with the parent node.

I appreciate any and all suggestions, but I would be more interested in learning about ways to make this work - this module has some very specific requirements that existing modules were not able to address. Thanks.

1 Answer 1


The function you're looking for is node_view():

$view_mode = 'teaser'; // Or 'full'
print render(node_view($node, $view_mode));

It's the same function that Drupal internally calls to display the node page/teaser so your template files will be honoured as you'd expect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.