I would like to override only the edit page of a certain content type. Theme developer module says:

page-"content_type".tpl.php < page-node-edit.tpl.php < page-node-"nid".tpl.php < page-node.tpl.php < page.tpl.php

If I use page-"content_type".tpl.php, it also overrides the node view page and if I use page-node-edit.tpl.php it overrides the edit page of all content types.

I tried the code below, and put it in my template.php but it doesn't work.

function my_theme_preprocess_page(&$vars) {
 if (isset($vars['node'])) {
    if ($edit_or_add=='edit' || $edit_or_add=='add') {
      $vars['template_files'][]='page-' . str_replace('_','-',$vars['node']->type . '-' . $edit_or_add);
    else {
      $vars['template_files'][]='page-' . str_replace('_','-',$vars['node']->type);
  • Can you explain a little more what you are doing? I suspect what you need involves editing the node edit form for your content type, rather than a template change, but I could be wrong.
    – mpdonadio
    Commented Dec 5, 2011 at 21:52

2 Answers 2

function my_theme_name_theme($existing, $type, $theme, $path) {
  return array(
    'story_node_form' => array(
        'arguments' => array('form' => NULL),
        'template' => 'node-story-edit'

This code from here worked for me, for example for the story content type.


In D6, putting this in your theme's _preprocess_page() hook should do it:

if (isset($vars['node'])) {
  $edit_or_add = basename($_GET['q']);

  if ($edit_or_add == 'edit' || $edit_or_add == 'add') {
    $vars['template_files'][]='page-cck-' . str_replace('_','-',$vars['node']->type . '-' . $edit_or_add);
  else {
    $vars['template_files'][]='page-cck-' . str_replace('_','-',$vars['node']->type);

Then create a page-cck-CONTENT-TYPE.tpl.php, page-cck-CONTENT-TYPE-edit.tpl.php and/or page-cck-CONTENT-TYPE-add.tpl.php and you should be all set. (By the way, I added the cck- on my sites to be overly clear as to what was going on, it's up to you.)

  • Sorry for my late reply.I tried name it phptemplate_preprocess_page(&$vars)but it returns the error Fatal error: Cannot redeclare phptemplate_preprocess_page() (previously declared. Any idea?
    – chinita7
    Commented Jan 17, 2012 at 1:24

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.