1

I would like to show a 'Delete' tab near the 'View' and 'Edit' tabs in the node page and insert a custom warning message and a view in it. If I create a view tab page with path /node/%/delete it works fine, but the submit button is missing and I can't figure out how to add it. Any idea?

2 Answers 2

4

By creating a view with path /node/%/delete, you have completely replaced the existing page (the delete confirmation form). According to Drupal logic, this is normal behavior.

What I would do is:

1) Do not use the page display of your view, but add a block display to the view. Add your message as view header. Place that block above the main page content and restrict it to the node/*/delete path.

2) Create custom module, implementing hook_menu_alter with one line of code (credits):

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

Of course you need to replace MODULENAME with the actual name of your module.

2
  • Instead of node/%/delete I used node/*/delete. Perfect. Many Thanks. Jan 19, 2013 at 16:09
  • 1
    You are completely right, my mistake. The % placeholder is used in hook_menu(_alter) while the * placeholder is used in block visibility settings. I'll update my answer. Jan 19, 2013 at 18:33
1

You can use hook_menu_alter to add the tab and hook_form_alter to add your message to the page. You can then create a view block and add the block to the content area for the node/*/delete path. Use the following code and replace MYMODULE with your module name:

/**
 * Implements hook_menu_alter().
 */
function MYMODULE_menu_alter(&$items) {
  $items['node/%node/delete']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
}


/**
 * Implements hook_form_alter().
 */
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if($form_id=='node_delete_confirm'){
    drupal_set_message('my msessage');
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.