page_example_baz

Versions
4.6 – 5
page_example_baz($alice = 0, $bob = 0)
6 – 7
page_example_baz($alice, $bob)

A more complex page callback that takes arguments.

The arguments are passed in from the page URL. The 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.

Code

developer/examples/page_example.module, line 115

<?php
function page_example_baz($alice, $bob) {
  // Make sure you don't trust the URL to be safe! Always check for exploits.
  if (!is_numeric($alice) || !is_numeric($bob)) {
    // We will just show a standard "access denied" page in this case.
    return drupal_access_denied();
  }

  $list[] = t("Alice's number was @number.", array('@number' => $alice));
  $list[] = t("Bob's number was @number.", array('@number' => $bob));
  $list[] = t('The total was @number.', array('@number' => $alice + $bob));

  return theme('item_list', $list);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.