0
我正在使用View Bulk Operation模塊對我的自定義視圖進行多重刪除,並在其中列出了我的內容。Drupal 7 VBO的鉤子form_alter不會觸發
但我要檢查一個值就知道我是否接受刪除內容或不... 我已經成功與多重選擇這樣做對我的看法/admin/content
與hook_form_alter()
但它不會觸發我這樣做對我的自定義視圖時...
我試過其他類似的鉤子:
hook_views_bulk_operations_form_alter()
這聽起來不錯......不過,這並不在所有hook_node_delete()
觸發可以有工作,但我有n Ø知道如何停止刪除過程中的函數時(exit;
或break;
只是拋出一個錯誤,我不知道爲什麼)
我這正常工作與「內容頁」的hook_form_later代碼:
function MODULE-NAME_form_alter(&$form, &$form_state, $form_id) {
foreach($form['nodes'] as $pnode)
{
if(is_array($pnode))
{
if(!isDeletable($pnode['#value'])) // my function which says if we can delete the content
{
$n = node_load($pnode['#value']);
$status = isset($n->workbench_moderation['current']->state) ? $n->workbench_moderation['current']->state : false;
$string = "This content won't be deleted : ".substr($pnode['#suffix'],0,-6); // substr to cut off the '</li>' !
drupal_set_message(t($string), 'warning');
unset($form['nodes'][''.$pnode['#value']]); // get the content off the form (my way to say that the content shouldn't be deleted)
}
}
}
}
hook_views_bulk_operations_form_alter()
如何觸發?