I am overriding node.tpl.php for a specific node (node--news.tpl.php) to display it differently in the front page. Instead of copying node.tpl.php code into node-news.tpl.php to display the node with the default rendering when we are not on the front page, I would rather prefer calling the base template implementation (node.tpl.php).

if ($is_front)
  // ...
  base_template(/* ... */);

Is that possible ?


Solution :

function template_preprocess_node(&$variables)
  if (drupal_is_front_page() && $variables['node']->type == 'news')
    $variables['theme_hook_suggestions'][] = 'node__news__front';

Then, simply edit the template file node--news--front.tpl.php

2 Answers 2


I would do this in the preprocess stage, eg, in your preprocess_node() hook, do something along the lines of:

if ($_GET['q']=='node') {                           // eg the frontpage (by default anyway) and not node/## (also then presumes this is a teaser view, too
  $foo=drupal_get_path_alias('node/' . $node->nid;  // or perhaps $foo=$node->path; works in D7?
  if ($foo=='news') {

I saw "along the lines of" because I am just now getting to know D7 vs D6 and I could have some typos in there, but the logic is to set the template file to the node-news.tpl.php one only when the user is looking at the front page and your news node is presented there.

But also, from what I have seen, node--news.tpl.php suggests that it should be used for nodes of TYPE news, so, there may need to be a different name here as well. So, if that's what you mean, you could do this instead:

if ($_GET['q']=='node' && $node->type=='news') {

and create a node--news--front.tpl.php file, or whatever the best practices name is :)

  • It works, thank you :) Drupal could (should) nevertheless offer a better (faster) solution. Mar 5, 2012 at 17:18

I have never tried this, but I suspect you can implement template_preprocess_node in your theme, use drupal_is_front_page, and if FALSE, remove the specific template from the $variables["theme_hook_suggestions"] array.

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.