Delete tab (MENU_LOCAL_TASK) for nodes and removing "delete" button from node forms
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;
}| Attachment | Size |
|---|---|
| deletetab.png | 107.53 KB |
Groups:
Login to post comments
admin_links
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.
Thank you, I will make a
Thank you, I will make a request on module queue regarding delete button.