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. 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.

Code

developer/examples/page_example.module, line 123

<?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);
  print theme('page', $content);
}
?>
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.