0

I've added a page template to override certain content types

function THEMENAME_preprocess_page(&$variables) {
  if( !empty($variables['node']) ) {
    $variables['theme_hook_suggestions'][] = 'page__node__' . $variables['node']->type;
  }
}

This successfully uses page--node--vendor.tpl.php instead of page.tpl.php

The problem is that it is also using this template when editing the node, which looks rather silly. How can I modify this to only use the template when viewing content and not when editing?

** Yes, I do want Drupal to use this theme when creating/editing content, and not a separate admin theme.

0

You could also key off of the path, eg, node/1 is the path for viewing node 1, whereby node/1/edit is the path when you are editing node 1, therefore you could look if arg(2) != 'edit' ...

| improve this answer | |
0

This was the most convenient variable I found in the $variables array to check whether I was viewing or editing

function THEMENAME_preprocess_page(&$variables) {
  $is_editing = isset($variables['page']['content']['system_main']['#node_edit_form']) && $variables['page']['content']['system_main']['#node_edit_form'];

  if( !empty($variables['node']) && !$is_editing ) {
    $variables['theme_hook_suggestions'][] = 'page__node__' . $variables['node']->type;
  }
}
| improve this answer | |
  • 1
    you could also key off of the path, eg, node/1 is the path for viewing node 1, whereby node/1/edit is the path when you are editing node 1, therefore you could look if arg(2)!='edit'... – Jimajamma Aug 30 '13 at 2:04

Your Answer

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