2

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?

1 Answer 1

1

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]);
  }
}
1
  • 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, 2012 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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