Search code examples
phpdrupal-7

content type not overriding in drupal7


I created a content type called custom content type..now I want to override the content type with the form id.I included bartik_theme in template.php and custom-content-type-node-form as my form id and I created custom-content-type-node-form.tpl.php in template in bartik..but am unable to override.I try to use dpm() function to print array structure that also not working.thank you in advance..

       I included this in template.php

         function bartik_theme() {
         return array(
          'custom_content_type_node_form' => array(
           'arguments' => array('form' => NULL),
           'template' => 'templates/custom-content-type-node-form',
           'render element' => 'form'
            ),
            );
            }

        I created  custom-content-type-node-form.tpl.php in template folder

           <?php
               dpm($form);

                  hide($form['body']);

                 print drupal_render_children($form['field_custom_image']);
                   print drupal_render_children($form['title']);

                     print drupal_render_children($form);
                    ?>

Solution

  • That's because your custom theme implementation is not in the theme hook suggestions array. Use "template_preprocess_page" hook to add a suggestion to the the hook suggestions array :

    function yourtheme_preprocess_page(&$vars) {
     //your checks here ...
     $vars['theme_hook_suggestions'][] = 'custom_content_type_node_form';
     //...
    }
    

    However if you want to change form element I suggest to use "hook_form_alter" or "hook_form_FORM_ID_alter" hook.