Drupal: Reuse the node edit form in a page

If you ever need to duplicate the functionality of the path of "/node/%node/edit", you can simply copy the following to and edit so it matches what you need.

In your menu hook, add this menu item:

$items['something/edit/%node'] = array(
  'page callback' => 'something_edit_page',
  'page arguments' => array(2),
  'type' => MENU_CALLBACK,
  'access callback' => 'node_access',
  'access arguments' => array('update', 1),
);

And then create the corresponding callback function to handle the request:

function something_edit_page($node) {
  require_once(drupal_get_path('module', 'node') . '/node.pages.inc');
  return node_page_edit($node);
}

So when you visit "/something/edit/%node", it will display the same things as it would on the normal edit node page (except the "View" and "Edit" tabs).

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog