Here's a basic menu structure I'm working with:
function events_menu()
{
$items = array();
$items['events'] = array(
'title' => 'Current Events',
'access callback' => true,
'page callback' => 'page_event',
'type' => MENU_CALLBACK,
);
$items['events/current'] = array(
'access callback' => true,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
);
$items['events/regions'] = array(
'title' => 'Event By Region',
'access callback' => true,
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
$items['events/range/%/to/%'] = array(
'title' => 'Current Events by Range',
'access callback' => true,
'page callback' => 'page_event_range',
'page arguments' => array(2, 4),
'type' => MENU_LOCAL_TASK,
/* Don't want this to be a tab.
I want it to activate the default tab */
);
return $items;
}
The URL (and default tab) events
displays some data. I'd like the URL events/range/%/to/%
to filter the data based on the passed URL parameters.
The hook_menu above works, but I don't want events/range/%/to/%
to be it's own tab. When you use the filtered URL, I want the default tab, Current Events, to remain active -- to give the illusion that you're looking at the same page as events
, only filtered. Can multiple URL's point to the same tab?
I guess I could handle the url parameters manually with arg()
in the events
page callback, but this seems hacky. Isn't there a way to do this using hook_menu?
Edit (stated more clearly):
Normally there are two tabs Current Events and Event By Region at the URLs events
and events/regions
. I want a hidden (callback only) url at events/range/%/to/%
. But when you visit it, I want the two tabs to remain visible and Current Events active - as if we'd never left that page.
I don't think it's possible to accomplish what you want only with hook menu. What you could do it use menu_set_active_trail
to make drupal make it look like the users is looking at the /events
page.
The above method might only work for Drupal 7
For Drupal 6 you could alter $_GET['q']
. This can, however, conflict with some modules like purl or globalredirect. This is not a pretty solution but it works. The best place to do this would be in the a custom module using hook_init
.