I've followed what previously worked in Drupal 6 in creating a separate template file for node/add/custom_content_type.

I've go this in my template.php:

function mytheme_theme() {
return array(
'business_case_justification_node_form' => array(
'arguments' => array('form' => NULL),
'path' => drupal_get_path('theme', 'mytheme') . '/templates',
'template' => 'business-case-justification-node-form',
'render element' => NULL,
)
);
}

I then created my business-case-justification-node-form.tpl.php file.
All of that works... when trying to do a node/add on the content type, drupal shows the barebones tpl.php file I have identified above in the 'template' line.

However the 'form' variable is null... always...

If I put dpm( get_defined_vars() ); in the tpl.php file, I get a $variables array. within that array is an unnamed array $variables[''] which holds a variety of information like #node, the fields etc etc.

How do I render the form elements now? drupal_render fails miserably. I can't find any documentation on this anywhere.
help!

Comments

Anonymous’s picture

As far as I know, path templates are built-in Drupal 7, so just do this:

page--node--add--blog.tpl.php (for blog)
page--node--add--story.tpl.php (for story)
etc.
etc.

Refresh cache!

PS Page template suggestions go into mytheme_preprocess_page(&vars), like this:
Drupal 7 example:

/**
 * Implementation of hook_preprocess_page().
 */
function mytheme_preprocess_page(&$vars) {

  // Node template suggestions like page--node--blog.tpl.php
  if (isset($vars['node'])) {
     $vars['theme_hook_suggestions'][] = 'page__node__' . str_replace('_', '--', $vars['node']->type);
  }

}

Good luck!

manhhainet’s picture

i implemented hook_preprocess_page():

function mybartik_preprocess_page(&$variables) {
  // Node template suggestions like page--node--blog.tpl.php
  if (isset($variables['node'])) {
     $vars['theme_hook_suggestions'][] = 'page__node__' . str_replace('_', '--', $vars['node']->type);
  }
}

then created file: page--node--add--article.tpl.php from page.tpl.php

and edit page--node--add--article.tpl.php few rows. but page is not changed

builderShawn’s picture

First off your code is a little messed up you are using $variables as the receiving var and then using $vars as the processing var... Once you fix that it should work.

raphael apard’s picture

function mytheme_theme() {
  return array(
    'business_case_justification_node_form' => array(
      'arguments' => array('form' => NULL),
      'path' => '/templates',
      'template' => 'business-case-justification-node-form',
      'render element' => 'form',
    )
  );
}

Raphael

_randy’s picture

adding the 'form' to the render element seems to have done the trick so far.