I am trying to make a link in a view which, when clicked on, will call a function in a custom module to make a database call. I have made a link by making a Global:custom text field (because thats the way it seemed I had to do it from some posts online), set it to a path accompanied with some arguments. I made a custom module used the hook_menu:
function example_menu() {
$items = array();
$items['path_name'] = array(
'title' => t('Example'),
'page callback' => 'my_callback',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
where function my_callback does a database call.
When I click on the link I just get a blank page with nothing on it. Which pieces am I missing here? The first thing I thought was that I needed to route the link to a page (hence the name 'page_callback') but how would I do this? All I really want done is a database call, I don't mind if you stay on the same page.
EDIT: Additionally, what I have found is that on the content management page there ares some errors on top which tell me that I'm missing arguments 1 through 4 (there were four arguments), which definitly can be part of the problem. The function starts off:
function example_my_callback($staff_action, $first_name, $last_name, $email)
and the url for the link was path_name?staff_action=[varible name found in views]...etc Is there any issue here?
return 'I was here';
or anything else, it will be painted on the screen on your page.'access callback' => array('user_access'),
to your menu but it is the default so not needed. but the menu system calls that callback with your argument which basically says your users can go to this page if s/he can access content (from permissions). you could also use'access callback' => TRUE,
and noaccess arguments
if you wanted anyone to be able to access the page.