Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php drupal7中的内容类型未重写_Php_Drupal 7 - Fatal编程技术网

Php drupal7中的内容类型未重写

Php drupal7中的内容类型未重写,php,drupal-7,Php,Drupal 7,我创建了一个名为custom content type的内容类型。现在我想用表单id覆盖该内容类型。我在template.php中包含bartik_主题,并将custom content type node form作为表单id,然后在bartik中的template中创建custom-content-type-node-form.tpl.php。但无法覆盖。我尝试使用dpm()用于打印阵列结构的函数也不起作用。提前感谢 I included this in template.ph

我创建了一个名为custom content type的内容类型。现在我想用表单id覆盖该内容类型。我在template.php中包含bartik_主题,并将custom content type node form作为表单id,然后在bartik中的template中创建custom-content-type-node-form.tpl.php。但无法覆盖。我尝试使用dpm()用于打印阵列结构的函数也不起作用。提前感谢

       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);
                    ?>
我把它包含在template.php中
函数bartik_theme(){
返回数组(
“自定义内容类型节点形式”=>数组(
'arguments'=>array('form'=>NULL),
“模板”=>“模板/自定义内容类型节点表单”,
'呈现元素'=>'表单'
),
);
}
我在template文件夹中创建了custom-content-type-node-form.tpl.php

这是因为您的自定义主题实现不在主题挂钩建议数组中。 使用“模板预处理页面”钩子将建议添加到钩子建议数组:

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

但是,如果您想更改表单元素,我建议使用“hook\u form\u alter”或“hook\u form\u ID\u alter”hook。

请查看drupal的建议。您可能根本不需要实现hook_主题