简体   繁体   中英

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. 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. I think I didn't understand it very well. It too difficulty than just make a tpl.php file.

so, My questions are.

  1. Is there any way to make a input theme file like, node--content--edit.tpl.php? ( I found, in page case, make a page--node--add--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. I put a code below but It didn't work. did I miss anything?

content-type name : 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. (adsfasdfkajsdhfkash) but nothing happened.

actually I just want to make a agreement box in my content-type (INPUT) but I have spent to much time. Can anyone help me?

Some people said, put theme() function in template.php in site/all/theme/bartik folder. 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. If you are adding that to the Bartik theme, then the function name should be bartik_theme() , not mycontent_theme() .

The code you are using contains a typo: it is arguments , not agruments . That property is not used in Drupal 7, though. Drupal 7 uses variables , or render element .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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