Delete tab (MENU_LOCAL_TASK) for nodes and removing "delete" button from node forms

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
delf's picture

This module adds a "delete" MENU_LOCAL_TASK to all nodes and removes "delete" button from all node forms. While this module is very simple and may not seem important for a developer, it does provide a significant improvement for content publishers/maintainers, especially to those who are new to Drupal.

Please leave your feedback.

Also, can I submit it as a contributed module?

deletetab.info:

; $Id: $
name = Delete Tab
description = Adds "delete" tab (MENU_LOCAL_TASK) for all nodes and disables default "delete" button on node forms.
package = Administration

project = "deletetab"
core = "6.x"

deletetab.module:

<?php
// $Id:$
/
* @file
* Adds "delete" tab (MENU_LOCAL_TASK) for all nodes and disables default "delete" button on node forms.
*/

/

* Implementation of hook_menu().
*/
function deletetab_menu(){
  $items = array();

  $items['node/%node/erase'] = array(
    'title' => 'Delete', 
    'access callback' => 'node_access',
    'access arguments' => array('delete', 1),
    'page callback' => 'deletetab_delete',
    'page arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,   
  ); 
   
  return $items;


/
* Redirects to default Drupal delete path
*/
function deletetab_delete($node) {
  drupal_goto('node/' . $node->nid . '/delete');
}

/

* Implementation of hook_form_alter().
* Removes "delete" button from node form.
*/
function deletetab_form_alter(&$form, &$form_state, $form_id) {
  if (deletetab_string_ends_with($form_id, 'node_form')) {
    unset($form['buttons']['delete']);
  }
}

/**
* Check whether $full_str ends with $end_str
*/
function deletetab_string_ends_with($full_str, $end_str)      {
  // Look at the end of full_str for the substring the size of end_str
  $full_str_end = substr($full_str, strlen($full_str) - strlen($end_str));
  // If it matches, it does end with EndStr
  return $full_str_end == $end_str;
}
AttachmentSize
deletetab.png107.53 KB

Comments

admin_links

Dave Reid's picture

Check out http://drupal.org/project/admin_links - it does the same thing except for removing the Delete button. Could easily be added. Don't think it's worth adding since it's duplicating an existing module.

Senior Drupal Developer for Lullabot | www.davereid.net | @davereid

Thank you, I will make a

delf's picture

Thank you, I will make a request on module queue regarding delete button.

For Drupal 7

jwjoshuawalker's picture

Sorry to post on such an old thread, but I did a google search to see if anyone had a quick solution for adding delete tab to nodes and this page came up so I thought it would be as good a place as any for this information.

If the goal is just to add a Delete tab next to the default View | Edit tabs on a node in Drupal 7, you can use this quickie:

function example_menu_alter(&$items) {
  $items['node/%node/delete']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
}

Thank you, drastik!

momchil_brashnyanov's picture

Thank you, drastik!

drastik, Thank You!

antojose's picture

drastik, Thank You!

Usability

Group organizers

Group categories

UX topics

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: