1

I am using zen drupal-7 sub theme. I have created a content type named edison. I need to change the node add form for the user. I've tried adding page--node--add--edison.tpl.php in template.php. I used the following code:

if (isset($variables['node'])) {
  $variables['theme_hook_suggestions'][] = 'page__node__' . str_replace('_', '--', $variables['node']->type);
}

When the $variables['theme_hook_suggestions'] variable is printed, it looks like this:

Array ( 
  [0] => page__node 
  [1] => page__node__add 
  [2] => page__node__add__edison 
  [3] => page__node__edison 
) 

The custom .tpl is not overriding the page.tpl.php.

1 Answer 1

2

The $variables['theme_hook_suggestions'][] only suggests theme for the node itself not the form to add content!

You have to let us know how exactly do you want to display your form. Some times a few CSS codes may be enough.

Anyway to theme the node add content you can use hook_form_alter to add some attributes to the form elements, add CSS classes or ... . You can also use Firebug to get the fields ID or class names then use CSS to theme them.

The following code

function THEME_form_alter(&$form, $form_state, $form_id) { 
      print $form_id;
}

gives you the ID of the form. Find the ID of the node add form and do the changes. like

function THEME_form_alter(&$form, $form_state, $form_id) { 
      if($form_id == "NODE_ADD_FORM")
            ////
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.