2

I have one content type called Restaurant, and I want to change the layout of this content type in the administrative area. When the administrator user adds/edits a Restaurant node, the layout should be my custom layout.

How can I change the whole layout?

4
  • See here drupal.stackexchange.com/questions/29353/…
    – niksmac
    Commented Jun 13, 2012 at 7:29
  • thanx.. but This will work for display front side it is not work in admin area. i have try this "page--node--add--article.tpl.php" for add page it is working but "page--node--edit--article.tpl.php" it is not working. but "page--node--edit.tpl.php" it is working for all content edit page but i want to work only on article. Commented Jun 13, 2012 at 7:37
  • You ca check for arguments in that node page itself. like node/add/CONTENTTYPE etc.
    – niksmac
    Commented Jun 13, 2012 at 8:59
  • sorry but it not work for me. Commented Jun 13, 2012 at 10:17

1 Answer 1

2

As shown in the comment at the beginning of theme_get_suggestions(), for a URL such as http://www.example.com/node/1/edit, the following default suggestions will be used.

  • page__node
  • page__node__%
  • page__node__1
  • page__node__edit

If you want to add page__node__edit__article as suggestion, you need to implement hook_preprocess_page() in a module. The following code works for any content type.

function mymodule_preprocess_page(&$variables) {
  if (!empty($variables['node']) && arg(2) == 'edit') {
    // (1)
    array_unshift($variables['theme_hook_suggestions'], 'page__node__edit__' . str_replace(array("/", "\\", "\0", '-'), array('', '', '', '_'), $variables['node']->type));
    // (1)
  }
}

If you want to be use not to apply the template file for, e.g., node/1/edit/revert, replace the code between // (1) with the following one.

$arg3 = arg(3);
if (empty($arg3)) {
  array_unshift($variables['theme_hook_suggestions'], 'page__node__edit__' . str_replace(array("/", "\\", "\0", '-'), array('', '', '', '_'), $variables['node']->type));
}
1
  • Thanx kiamlaluno its work for me. Commented Jun 13, 2012 at 10:25

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.