Posted by delf on September 3, 2009 at 10:04pm
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 |
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.
Senior Drupal Developer for Lullabot | www.davereid.net | @davereid
Thank you, I will make a
Thank you, I will make a request on module queue regarding delete button.
For Drupal 7
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!
Thank you, drastik!
drastik, Thank You!
drastik, Thank You!