php - Call a function from a link in drupal 7 -
i'm creating table delete field in every row. delete fields links. i'm wondering; how can call function (to delete data database) when click link.
the code the table:
$header = array("booking day" , "where" , "nr of people", "cancel"); $rows = null; foreach ($res $booking) { if(isset($venues[$booking->nid]->title)){ $rows[] = array( date("d-m-y", $booking->date), $venues[$booking->nid]->title, $booking->num_guests, l('delete', "link here" ), ); } } i've found example online dictates me make new menu page this:
$items['node/%node/delete_slot'] = array( 'title' => 'delete slot', 'page callback' => 'bookings_delete_booking', 'page arguments' => array(2), 'access arguments' => array('access content'), // whatever see above 'type' => menu_callback );
and new function this:
function bookings_delete_booking($identifier_for_what_percent_is) { dsm('test'); }
when click link goes 404 page.
does have idea how make work?
-thanks
how table being generated? not generate via view has node[delete] option included?
you need flush cache (page registry) not pick code up.
also want page arguments line following
'page arguments' => array(1) as argument positioned second in url
Comments
Post a Comment