function ds_extras_contextual_links_view_alter in Display Suite 7
Implements hook_contextual_links_view_alter().
File
- modules/
ds_extras/ ds_extras.module, line 602 - Display Suite extras main functions.
Code
function ds_extras_contextual_links_view_alter(&$element, $items) {
if (isset($element['#element']['#entity_type']) && user_access('administer content types') && module_exists('field_ui')) {
$entity_type = $element['#element']['#entity_type'];
$bundle = $element['#element']['#bundle'];
$view_mode = isset($element['#element']['#view_mode']) ? $element['#element']['#view_mode'] : 'default';
// Check if we have a configured layout. Do not fallback to default.
$layout = ds_get_layout($entity_type, $bundle, $view_mode, FALSE);
// Get the manage display URI.
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
// Check view mode settings.
$view_mode_settings = field_view_mode_settings($entity_type, $bundle);
$overriden = !empty($view_mode_settings[$view_mode]['custom_settings']) ? TRUE : FALSE;
if (empty($layout) && !$overriden) {
$admin_path .= '/display';
}
else {
$admin_path .= '/display/' . $view_mode;
}
$element['#links']['manage-display'] = array(
'title' => t('Manage display'),
'href' => $admin_path,
'query' => drupal_get_destination(),
);
}
}