0

I used the CCK module to create a content type that has three fields (title, description, and body). I want to overwrite two pages: one is where there is a "create content" navigation located on the left page; the other one is where I click on "Create page" and which displays the form page.

2
  • 1
    You should explain better what you are trying to accomplish, and why. Normally, there isn't any reason to alter those system pages. The more details you give, the more specific the answer will be; differently the answer will be something like "create a custom module that implements hook_menu_alter()."
    – apaderno
    Apr 5, 2011 at 2:11
  • i want to overwrite the create page(a content type), which generated by the CCK module
    – enjoylife
    Apr 5, 2011 at 3:49

1 Answer 1

1

To alter a node edit from, you need to create a custom module that implements hook_form_alter(), using code similar to the following one:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    $node = $form['#node'];
    // ...
    // @todo Add the code you need.
    // ...
  }
}

For examples of actual implementations of hook_form_alter() that alter the node edit form, see book_form_alter(), locale_form_alter() (which alters also other forms), menu_form_alter(), path_form_alter(), and taxonomy_form_alter().

2
  • form['type']['#value'] ,$form['#node'],$form['type']what're these variables meaning?
    – enjoylife
    Apr 5, 2011 at 6:16
  • 1
    $form['type'] is the form field containing the content type identifier; $form['type']['#value'] contains the string that identifies the content type. $form['#node'] contains the node object for the node being edited.
    – apaderno
    Apr 5, 2011 at 11:50

Your Answer

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

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