简体   繁体   English

如何在内容类型Drupal7中修改输入表单

[英]How to modify input form in content-type Drupal7

Can any one help me? 谁能帮我? I have been many time looking around to solve this problem. 我花了很多时间环顾四周以解决这个问题。 Now I know, how to make a new content type and how to theme its output. 现在,我知道了如何制作新的内容类型以及如何为其输出设置主题。 It was simple. 很简单。 just make a 'node--content-type-name.tpl.php' file in my template folder. 只需在我的模板文件夹中创建一个“ node--content-type-name.tpl.php”文件即可。 Now I want to theme input form. 现在我要主题输入表格。

when I find its way, just said, Make a new module or put some code in template.php but I tried thousand of time but I didn't make any result. 当我找到方法时,只是说,制作一个新模块或在template.php中放入一些代码,但我尝试了数千次,但未取得任何结果。 I think I didn't understand it very well. 我想我不太了解。 It too difficulty than just make a tpl.php file. 比仅仅制作一个tpl.php文件太困难了。

so, My questions are. 所以,我的问题是。

  1. Is there any way to make a input theme file like, node--content--edit.tpl.php? 有什么方法可以制作输入主题文件,例如node--content--edit.tpl.php? ( I found, in page case, make a page--node--add--content-type.tpl.php) (我发现在页面情况下,制作一个页面-节点-添加-content-type.tpl.php)

  2. Do I have to make a custom module? 我必须制作一个自定义模块吗? if I want to theme input in content-type? 是否要以内容类型输入主题?

  3. Some people said, put theme() function in template.php in site/all/theme/bartik folder. 有人说,将theme()函数放在site / all / theme / bartik文件夹中的template.php中。 I put a code below but It didn't work. 我在下面放了一个代码,但是没有用。 did I miss anything? 我有错过什么吗?

content-type name : mycontent 内容类型名称:mycontent

function mycontent_theme() {
    return array(
        'mycontent_node_form' => array(
        'agruments' => array('form' => NULL),
        'template' => 'mycontent-node-form',
        ),
    );
}

then I made mycontent-node-form.tpl.php file in the site/all/theme/bartik/template folder and I put just random text in it. 然后我在site / all / theme / bartik / template文件夹中制作了mycontent-node-form.tpl.php文件,并在其中放置了随机文本。 (adsfasdfkajsdhfkash) but nothing happened. (adsfasdfkajsdhfkash),但没有任何反应。

actually I just want to make a agreement box in my content-type (INPUT) but I have spent to much time. 实际上,我只是想在内容类型(INPUT)中创建一个协议框,但是我已经花了很多时间。 Can anyone help me? 谁能帮我?

Some people said, put theme() function in template.php in site/all/theme/bartik folder. 有人说,将theme()函数放在site / all / theme / bartik文件夹中的template.php中。 I put a code below but It didn't work. 我在下面放了一个代码,但是没有用。 Did I miss anything? 我有想念吗?

Instead of mycontent , you should use the short name of the theme. 代替mycontent ,您应该使用主题的简称。 If you are adding that to the Bartik theme, then the function name should be bartik_theme() , not mycontent_theme() . 如果要将其添加到Bartik主题中,则函数名称应为bartik_theme() ,而不是mycontent_theme()

The code you are using contains a typo: it is arguments , not agruments . 您使用的代码包含一个错字:它是参数 ,而不是agruments That property is not used in Drupal 7, though. 不过,在Drupal 7中未使用该属性。 Drupal 7 uses variables , or render element . Drupal 7使用变量render元素

function bartik_theme() {
  return array(
    'mycontent_node_form' => array(
      'render element' => array('form' => NULL),
      'template' => 'mycontent-node-form',
    ),
  );
}

As side note, if you are adding functions to an already enabled module/theme, you need to first disable it, and then re-enabled it, as Drupal caches the name of some functions implemented by modules/themes. 附带说明一下,如果要将功能添加到已启用的模块/主题中,则需要先禁用它,然后再重新启用它,因为Drupal会缓存由模块/主题实现的某些功能的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM