Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have a node template named node-"content-type-name".tpl.php which overrides the default node.tpl.php for this content type.

But this template file is applied to also node revision pages. Is there anyway I can apply the node template file to just node view/edit page without revision page?

share|improve this question
add comment (requires an account with 50 reputation)

1 Answer

I don't have a D6 site around with revisions enabled so I can't test this, but the following code should disable the custom template for the revision pages:

function MYTHEME_preprocess_node(&$vars) {
  $template_name = 'node-content-type-name';

  // Work out if we're on a revision page
  $on_revision_page = arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions';

  // See if the rogue template file is available as one of the suggestions.
  $template_index = array_search($template_name, $vars['template_files']);

  if ($on_revision_page && $template_index !== FALSE) {
    // Remove the rogue template file from the suggestions.
    unset($vars['template_files'][$template_index]);
  }
}
share|improve this answer
Thanks for the code but it doesn't work and throw this error warning: array_search() expects parameter 2 to be array, null given in for this line $template_index = array_search($template_name, $vars['template_files']); – chinita7 Jul 13 '12 at 18:50
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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