By rockitdev on
I'm working on learning more module development, and i'm stumped on a really simple example here.
/**
* Implementation of hook_menu().
*/
function example_Menu() {
$items['maps'] = array(
'title' => 'Find Us',
'description' => 'Use the map to locate our facilities.',
'page callback' => 'example_map',
'page arguments' => array('all'),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['maps/%'] = array(
'title' => 'Find Us',
'description' => 'Use the map to locate our facilities.',
'page callback' => 'example_map',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/* I want this function to take either a default argument of all for the maps/ url or pass in a var if there is an arg past maps/*/
function example_map($args) {
/* take the value of what is passed into the function and output it in a simple string. */
$output = t('This is the output of my argument... @args', $args);
return $output;
}
Comments
Two changes 'page
Two changes
should be
and change
to
You will need to clear the menu cache after changing example_menu().
thanks. my function just
thanks. my function just outputs
This is the output of my argument... @args'
Should in place of @args, it say all?
$output = t('This is the
$output = t('This is the output of my argument... @args', array('@args' => $args));awesome. that fixes it if i
awesome. that fixes it if i hit a url of /maps/1 i see 1 output. but if i just hit maps/ shouldn't i get an output of all?
Try removing 'page arguments'
Try removing
'page arguments' => array(1),, if I recall correctly you only want to specify required arguments.Works now. Thanks all for the assistance.