By default, after node delete in Drupal CMS we are redirectem onto the content list page. However, if we develop custom modules with custom content lists or tables (ie. Drupal-based online store, where we shall have custom products list table), we shall get custom redirection path. There are two common possibilities to do this in a right way. We can use 'destination' param in custom node delete url by this way:
<?php
$destination = 'destination=custom_page_url';
print l('Delete', 'node/' . $node->nid . '/delete', array('query' => $destination));
?>
After node delete action Drupal will redirect onto 'custom_page_url' thankfully to 'destination' param in url query.
Another way is to create custom hook on Drupal node delete form by hook_form_alter() function:
<?php
function custom_module_form_alter($form, &$form_state, $form_id) {
switch($form_id) {
case 'node_delete_confirm':
$form['#submit'][] = '_custom_redirect_after_delete';
break;
}
return $form;
}
function _custom_redirect_after_delete($form, &$form_state) {
$form_state['redirect'] = 'custom_page_url';
}
?>
After the node delete form is send, Drupal will redirect onto 'custom_page_url' added into the form_state params by custom function. Second method is available by developing simple custom module (http://drupal.org/node/206753).
Comments
DesignEnd
22-12-2011 20:52
Fixed now, thx!
Chintan
21-12-2011 11:02
FOR D6
'query' => "destination=custom_page_url" worked for me not $destination varaible
l(t('Delete'),'node/'.$row->nid.'/delete',array('query' => "destination=custom_page_url"))
sadegh
23-08-2011 00:31
Leave a comment