You are here

function views_megarow_node_page_edit in Views Megarow 7

Overrides the node edit callback.

See also

node_page_edit().

1 string reference to 'views_megarow_node_page_edit'
views_megarow_menu_alter in ./views_megarow.module
Implements hook_menu_alter().

File

./views_megarow.module, line 498

Code

function views_megarow_node_page_edit($node) {

  // If the url executing the node edit menu item is from a megarow,
  // let's hook into megarow form rendering instead of the classic
  // output.
  if (preg_match('`^display_megarow/[0-9]+/node/[0-9]+/edit$`', $_GET['q'])) {

    // Add a flag for the node edition form.
    $node->from_megarow = TRUE;

    // This is a duplication of the default behavior.
    $type_name = node_type_get_name($node);
    $title = t('<em>Edit @type</em> @title', array(
      '@type' => $type_name,
      '@title' => $node->title,
    ));
    drupal_set_title($title, PASS_THROUGH);
    $output = drupal_get_form($node->type . '_node_form', $node);

    // Instead of return the form, pass it to views megarow to display it.
    return views_megarow_display($title, $output, $node->nid);
  }
  else {

    // Otherwise fallback on the default behavior.
    $node->from_megarow = FALSE;
    return node_page_edit($node);
  }
}