I have recently installed Drupal 7 and am trying to create a custom node EDIT form.
In Drupal 6 I would do the following in hook_theme():

<?php
    $reg
['bgshouse_node_form'] = array(
     
'arguments' => array('form' => NULL),
     
'template' => 'node-bgshouse-edit'
   
);
    return
$reg;
?>

I of course tried this in Drupal 7, but could not get it to work.
After that failed (and I read some docs, and poured thru some more docs), I tried something like this in hook_theme():

<?php
    $reg
['gstcourse_node_form'] = array(
     
'arguments' => array(
         
'form' => NULL,
      ),
     
'template' => 'node-gstcourse-edit',
     
'render element' => 'elements',
     
'preprocess functions' => array('template_preprocess','template_preprocess_node'),
      );
?>

And that *partially* worked (it had errors in the page because of some missing variables, and it just didnt' seem right that I was supposed to populate the "preprocess functions" array since no one else was ever doing that in any of the examples I found).
So, I scrapped that and tried this:

<?php
function gstmain_preprocess_page(&$vars, $hook) {
  if (isset(
$vars['node'])) {
 
// If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
  
$vars['theme_hook_suggestions'][] = 'page__'. str_replace('_', '--', $vars['node']->type);
  
  
// This works, but it replaces the entire PAGE, not just the node portion
   // template file will be: node--[content-type]--edit.tpl.php
  
$vars['theme_hook_suggestions'][] = 'node__'. str_replace('_', '--', $vars['node']->type) . '__edit';
  }
}
?>

That worked, but not in the way I wanted...it requires me to replace the entire PAGE (not just the NODE) portion of the page.
(and my node--gstcourse--edit.tpl.php is a supposed to just include the NODE not the page)
So, I tried this:

<?php
function gstmain_preprocess_node(&$vars) {
  if (isset(
$vars['node'])) {  
  
// This works, but it replaces the entire PAGE, not just the node portion
   // template file will be: node--[content-type]--edit.tpl.php
  
$vars['theme_hook_suggestion'] = 'node__'. str_replace('_', '--', $vars['node']->type) . '__edit';
  }
}
?>

This didn't work at all, since my node--gstcourse--edit.tpl.php doesn't have ANY "page" markup in it, just NODE markup.

What I would like is the method for JUST replacing the "node" portion of the page. I would prefer if my page.tpl.php stayed *untouched* and I could just make mods to the node--*--edit.tpl.php for content types (otherwise, everytime I make a change to the site structure, I will have to edit ALL the various page--*--edit.tpl.php file, and that just doesn't seem to make sense).

Perhaps I am doing something wrong...I sentp 5-8 hrs today trying to get this to work and it seems others have had similar problems (one big issues is people that don't keep track of the current "theme" which can change under D7 since you have a "main" theme and an "admin" theme...).

So, if anyone wants to let me know what the *correct* method is (For replacing the EDIT form of a content type with a custom form) I would *greatly* appreciate it.

Thanks.

Andrew.

Comments

mollman’s picture

This link talks about the module-side of the theming - http://drupal.org/node/1092122 (Theming Node Forms in Drupal 7)

hth

adf1969’s picture

hth:

Thanks, I found that link last night.
Not sure how I missed that.
I will post my "thoughts" for others once I get finished solving a "sorting" issue in the field_collection module ;)

pc-wurm’s picture

Hi adf1969, were you able to theme field_collection forms? I am theming a node form, but having hard time to provide a template file for field collections.