function views_ui_edit_page_display_tabs
Adds tabs for navigating across Displays when editing a View.
This function can be called from hook_menu_local_tasks_alter() to implement these tabs as secondary local tasks, or it can be called from elsewhere if having them as secondary local tasks isn't desired. The caller is responsible for setting the active tab's #active property to TRUE.
Parameters
view $view: The view which will be edited.
string $display_id: The display_id which is edited on the current request.
2 calls to views_ui_edit_page_display_tabs()
- views_ui_edit_page_display in includes/
admin.inc - Helper function to return the used display_id for the edit page.
- views_ui_render_display_top in includes/
admin.inc - Render the top of the display so it can be updated during ajax operations.
File
-
includes/
admin.inc, line 1525
Code
function views_ui_edit_page_display_tabs(view $view, $display_id = NULL) {
$tabs = array();
// Create a tab for each display.
foreach ($view->display as $id => $display) {
$tabs[$id] = array(
'#theme' => 'menu_local_task',
'#link' => array(
'title' => views_ui_get_display_label($view, $id),
'href' => 'admin/structure/views/view/' . $view->name . '/edit/' . $id,
'localized_options' => array(),
),
);
if (!empty($display->deleted)) {
$tabs[$id]['#link']['localized_options']['attributes']['class'][] = 'views-display-deleted-link';
}
if (isset($display->display_options['enabled']) && !$display->display_options['enabled']) {
$tabs[$id]['#link']['localized_options']['attributes']['class'][] = 'views-display-disabled-link';
}
}
// If the default display isn't supposed to be shown, don't display its tab,
// unless it's the only display.
if (!views_ui_show_default_display($view) && $display_id != 'default' && count($tabs) > 1) {
$tabs['default']['#access'] = FALSE;
}
// Mark the display tab as red to show validation errors.
$view->validate();
foreach ($view->display as $id => $display) {
if (!empty($view->display_errors[$id])) {
// Always show the tab.
$tabs[$id]['#access'] = TRUE;
// Add a class to mark the error and a title to make a hover tip.
$tabs[$id]['#link']['localized_options']['attributes']['class'][] = 'error';
$tabs[$id]['#link']['localized_options']['attributes']['title'] = t('This display has one or more validation errors; please review it.');
}
}
return $tabs;
}