Drupal 6 absolute wildcards in _menu (), is this possible?

You can handle all wildcards in the _menu () module.

I know about certain wildcards like

display/page/% but this will not work for paths display/page/3/andOrderBy/Name

what If I want to handle an unpredictable amount of parameters like

display/page/3/12/45_2/candy/yellow/bmw/turbo

I want to have one display/*_menu () path to handle all ARGUMENTS.

How can i do this?

+3
source share
2 answers

Drupal will pass any additional URLs as additional parameters to your callback function hook_menu- use func_get_args () in your callback to get them.

, display/page/%, display/page/3/andOrderBy/Name, "3" , "andOrderBy" "Name" .

:

function yourModuleName_display_callback($page_number) {
  // Grab additional arguments
  $additional_args = func_get_args();
  // Remove first one, as we already got it explicitely as $page_number
  array_shift($additional_args);
  // Check for additional args
  if (!empty($additional_args)) {
    // Do something with the other arguments ...
  }
  // other stuff ...
}
+3

ah;)

.

function mysearch_menu() {
$items['mysearch/%'] = array(
'page callback' => 'FN_search',
'access callback' => TRUE,
);
return $items;
}


function FN_search()
{
    return print_r(func_get_args(),true);
};
0

Source: https://habr.com/ru/post/1719083/


All Articles