function search_api_page_search_api_page_menu_alter in Search API Pages 7
Alters available menu items based on a defined task.
Used as a "hook menu alter" callback in search_api_page_search_api_page_page_manager_tasks().
1 string reference to 'search_api_page_search_api_page_menu_alter'
- search_api_page_search_api_page_page_manager_tasks in plugins/
tasks/ search_api_page.inc - Implements a specialized version of hook_page_manager_task_tasks().
File
- plugins/
tasks/ search_api_page.inc, line 47 - Handles the 'search api page' override task.
Code
function search_api_page_search_api_page_menu_alter(&$items, $task) {
// Go through each search page.
foreach (search_api_page_load_multiple(FALSE) as $page => $info) {
if (variable_get('search_api_page_search_api_page_disabled_' . $info->machine_name, TRUE)) {
continue;
}
$path = $info->path;
// If the page was deleted in the meantime, the menu entry might not exist
// anymore.
if (empty($items[$path]['page callback'])) {
continue;
}
$callback = $items[$path]['page callback'];
if ($callback == 'search_api_page_view' || variable_get('page_manager_override_anyway', FALSE)) {
$items["{$path}"]['page callback'] = 'search_api_page_search_api_page_page';
$items["{$path}"]['file path'] = $task['path'];
$items["{$path}"]['file'] = $task['file'];
}
else {
// Automatically disable this task if it cannot be enabled.
variable_set('search_api_page_search_api_page_disabled_' . $page, TRUE);
if (!empty($GLOBALS['search_api_page_enabling_search_api_page'])) {
drupal_set_message(t('Page manager module is unable to enable @path because some other module already has overridden with %callback.', array(
'%callback' => $callback,
'@path' => $path,
)), 'error');
}
}
}
}