page_example_baz

Definition

page_example_baz($alice = 0, $bob = 0)
developer/examples/page_example.module, line 127

Description

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

Code

<?php
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;
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.