Same name and namespace in other branches
  1. 4.6.x developer/examples/page_example.module \page_example_baz()
  2. 5.x developer/examples/page_example.module \page_example_baz()

A more complex page callback that takes arguments.

The arguments are passed in from the page URL. They are always the next elements of the path after the page location. Because of this, if the URL of the page is moved later, this function does not need to be changed to accomodate the move. It's a good idea to always provide default values for the parameters

1 string reference to 'page_example_baz'
page_example_menu in developer/examples/page_example.module
Implementation of hook_menu().

File

developer/examples/page_example.module, line 131
This is an example outlining how a module can be used to display a custom page at a given URL.

Code

function page_example_baz($alice = 0, $bob = 0) {

  // 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.
    drupal_access_denied();
    return;
  }
  $list[] = "Alice's number was {$alice}.";
  $list[] = "Bob's number was {$bob}.";
  $list[] = 'The total was ' . ($alice + $bob) . '.';
  $content = theme('item_list', $list);
  return $content;
}