I've added a tab adjacent to the event "Info and Settings" configuration tab, using hook_civicrm_tabset(), but when I link to the URL for that tab, the "Info and Settings" tab is displayed. This behavior is different from that of native tabs, such as "Location": I can type in the URL for that tab, and the tab is correctly selected.
Question: How can I get my "My Settings" tab to display itself from a URL in a way that's equivalent to the behavior of native tabs such as Location?
Here are some examples of native URLs that work as expected, and my custom tab which does not.
"Info and Settings" tab
http://example.l/civicrm/event/manage/settings?reset=1&action=update&id=23
"Location" tab
http://example.l/civicrm/event/manage/location?reset=1&action=update&id=23
"My Settings" tab
http://example.l/civicrm/event/manage/mysettings?reset=1&action=update&id=23
Example code (slightly redacted for public viewing)
/**
* Implements hook_civicrm_tabset().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tabset/
*/
function myextension_civicrm_tabset($tabsetName, &$tabs, $context) {
if ($tabsetName == 'civicrm/event/manage') {
if ($eventId = CRM_Utils_Array::value('event_id', $context)) {
$tab['mysettings'] = array(
'title' => E::ts('My Settings'),
'link' => NULL, // 'link' is automatically provided if we're under the 'civicrm/event/manage' path.
'class' => 'ajaxForm', // allows form to re-load itself on save.
'valid' => _myextension_EventHasMySettings($eventId), // indicates whether tab has actively used settings.
'active' => TRUE,
'current' => FALSE, // setting this to FALSE prevents the tab from pre-loading
// focus when the page is loaded.
);
}
else {
$tab['mysettings'] = array(
'title' => E::ts('My Settings'),
'url' => 'civicrm/event/manage/mysettings',
'field' => 'is_my_settings',
);
}
//Insert this tab into position 1
$tabs = array_merge(
array_slice($tabs, 0, 1),
$tab,
array_slice($tabs, 1)
);
}
// Set mysettings tab as enabled/disabled in configuration popup-menu, on manage events listing screen.
if ($tabsetName == 'civicrm/event/manage/rows' && $eventId = CRM_Utils_Array::value('event_id', $context)) {
$tabs[$eventId]['is_my_settings'] = _myextension_EventHasMySettings($eventId);
}
}