Drupal: Reuse the node edit form in a page

0 Comments

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:

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

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

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

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