1

I'm seeking to show an extra form on node edit/add page. My function is this:

function mymodule_page_build(&$page) {
  $node = menu_get_object();
  if($node && $node->type == "object") {
    $page['page_bottom'][] = drupal_get_form('mymodule_form');

How can I check that current page is node edit/add page with a specific type like object?

1 Answer 1

1

The request_path() function can lookup the current path to determine what page is being rendered.

  if (request_path() == 'node/add/object') {
    // @TODO: Add code
  }
  else if (preg_match('/node\/\d+\/edit/', request_path())) {
    $node = menu_get_object();
    if ($node->type == 'object') {
      // @TODO: Add code for editing node
    }
  }

Your Answer

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

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