1 menu_example.module menu_example_arg_optional_to_arg($arg)

Utility function to provide default argument for wildcard.

A to_arg() function is used to provide a default for the arg in the wildcard. The purpose is to provide a menu link that will function if no argument is given. For example, in the case of the menu item 'examples/menu_example/default_arg/%menu_example_arg_optional' the third argument is required, and the menu system cannot make a menu link using this path since it contains a placeholder. However, when the to_arg() function is provided, the menu system will create a menu link pointing to the path which would be created with the to_arg() function filling in the %menu_example_arg_optional.


string $arg: The arg (URL fragment) to be tested.

Related topics


modules/examples/menu_example/menu_example.module, line 544
Module file for menu_example.


function menu_example_arg_optional_to_arg($arg) {
  // If our argument is not provided, give a default of 99.
  return (empty($arg) || $arg == '%') ? 99 : $arg;