I have created a custom table, and using views I have created a view of the data in thtat table.
Now I need an easy way of removing rows in that table, so I created a trigger that can remove the line, but it don't appear on "Selected operations:"; what else do I need to do?
function cc_projects_action_info() {
return array(
'cc_projects_deleteData_action' => array(
'description' => 'Delete a row',
'type' => 'cc_projecte_data',
'configurable' => FALSE,
'hooks' => array('any' => TRUE),
),
);
}
function cc_projects_deleteData_action(&$object, $context = array()) {
$nid=db_result(db_query("SELECT p.project_nid FROM {node_cc_projects_data} p WHERE pid = %d", $pid));
$node=node_load($nid);
if (node_access('update', $node)) {
db_query("DELETE FROM {node_cc_projects_data} WHERE pid = %d",$pid);
}
}
function cc_projects_bulk_operations_views_bulk_operations_object_info() {
return array(
'comment' => array(
'type' => 'cc_project_data',
'base_table' => 'node_cc_projects_data',
'load' => '_cc_projects_loadDataLine',
'title' => 'pid',
),
);
}
function _cc_projects_loadDataLine($pid){
return db_fetch_object(db_query("SELECT * FROM {node_cc_projects_data} WHERE pid = %d", $pid));
}
Comments
Comment #1
enboig commentedSolved at last, I paste the correct code here just if sometime is useful to anybody:
Comment #2
infojunkieThanks for documenting your fix. As far as I can tell from diffing between the original and fixed code, you had forgotten to change the key of your
views_bulk_operations_object_info()entry from 'comment' to 'cc_project_data'. Is that correct?Comment #3
enboig commentedYes, that was the problem; the first time I copy&pasted and missed to change it.