1

How can I change the behavior of search_menu() hook, not changing the search.module code?

I want to change it from:

function search_menu() {
  //...
  foreach (module_implements('search') as $name) {
    $items['search/'. $name .'/%menu_tail'] = array(
      'title callback' => 'module_invoke',
      'title arguments' => array($name, 'search', 'name', TRUE),
      'page callback' => 'search_view',
      'page arguments' => array($name),
      'access callback' => '_search_menu',
      'access arguments' => array($name),
      'type' => MENU_LOCAL_TASK,
      'parent' => 'search',
      'file' => 'search.pages.inc',
    );
  }
  return $items;
}

to:

function search_menu() {
  //...
  foreach (module_implements('search') as $name) {
    $items['search/'. $name .'/%menu_tail'] = array(
      'title callback' => 'module_invoke',
      'title arguments' => array($name, 'search', 'name', TRUE),
      'page callback' => 'search_view',
      'page arguments' => array($name),
      'access callback' => '_search_menu',
      'access arguments' => array($name),
      'type' => MENU_CALLBACK,
      'parent' => 'search',
      'file' => 'search.pages.inc',
    );
  }
  return $items;
}

to hide tabs on search page.

Thanks!

artyom.stv
  • 2,097
  • 1
  • 24
  • 42

1 Answers1

1

Do not hack core. Check out hook_menu_alter instead.

Matt V.
  • 9,703
  • 10
  • 35
  • 56
  • Thank you very much! That is exactly what I was looking for! :) The only hack I had to do in the core: I changed search pager size from `10` to `variable_get('search_results_per_page', 10)`. – artyom.stv Feb 28 '11 at 17:04
  • That sounds like a patch that might be worth contributing. – Matt V. Feb 28 '11 at 17:17