function page_example_arguments in Examples for Developers 6
Same name and namespace in other branches
- 7 page_example/page_example.module \page_example_arguments()
A more complex page callback that takes arguments.
The arguments are passed in from the page URL. In our hook_menu implementation we instructed the menu system to extract the last two parameters of the path and pass them to this function as arguments.
Related topics
1 string reference to 'page_example_arguments'
- page_example_menu in page_example/
page_example.module - Implementation of hook_menu().
File
- page_example/
page_example.module, line 226 - This is an example outlining how a module can be used to display a custom page at a given URL.
Code
function page_example_arguments($first, $second) {
// Make sure you don't trust the arguments to be safe! Always check for exploits.
if (!is_numeric($first) || !is_numeric($second)) {
// We will just show a standard "access denied" page in this case.
drupal_access_denied();
return;
// We actually don't get here.
}
$list[] = t("First number was @number.", array(
'@number' => $first,
));
$list[] = t("Second number was @number.", array(
'@number' => $second,
));
$list[] = t('The total was @number.', array(
'@number' => $first + $second,
));
return theme('item_list', $list);
}