You are here

function ds_extras_entity_view_alter in Display Suite 7

Same name and namespace in other branches
  1. 8.2 modules/ds_extras/ds_extras.module \ds_extras_entity_view_alter()
  2. 8.3 modules/ds_extras/ds_extras.module \ds_extras_entity_view_alter()
  3. 7.2 modules/ds_extras/ds_extras.module \ds_extras_entity_view_alter()

Implements hook_entity_view_alter().

File

modules/ds_extras/ds_extras.module, line 904
Display Suite extras main functions.

Code

function ds_extras_entity_view_alter(&$build, $entity_type) {
  static $loaded = array();

  // If views and core doesn't send information along on the entity,
  // Display suite doesn't have a context to render the layout.
  if (!isset($build['#entity_type']) || !isset($build['#bundle'])) {
    return;
  }
  $bundle = $build['#bundle'];
  $view_mode = $build['#view_mode'];
  if ($overridden_view_mode = ds_extras_get_view_mode()) {
    $view_mode = $overridden_view_mode;
  }
  $layout = ds_get_layout($entity_type, $bundle, $view_mode);

  // Page title options.
  if (variable_get('ds_extras_hide_page_title', FALSE)) {
    $page_title =& drupal_static('ds_page_title');
    if (isset($layout['settings']['hide_page_title']) && $layout['settings']['hide_page_title'] == 1) {
      $page_title['title'] = '';
    }
    elseif (isset($layout['settings']['hide_page_title']) && $layout['settings']['hide_page_title'] == 2 && !empty($layout['settings']['page_option_title'])) {
      $contexts = array();
      $id = arg(0) == 'taxonomy' ? arg(2) : arg(1);
      $entity = entity_load($entity_type, array(
        $id,
      ));
      ds_create_entity_context($entity_type, $entity[$id], $contexts);
      $title = $layout['settings']['page_option_title'];
      $title = filter_xss_admin(ctools_context_keyword_substitute($title, array(), $contexts));
      $page_title['title'] = $title;
      $page_title['head_title'] = $title;
    }
  }

  // Disable blocks.
  if (isset($layout['settings']['hide_sidebars']) && !isset($loaded[$entity_type][$bundle][$view_mode])) {

    // Store the setting.
    $loaded[$entity_type][$bundle][$view_mode] = TRUE;

    // Disable blocks.
    if (isset($layout['settings']['hide_sidebars']) && $layout['settings']['hide_sidebars']) {
      ctools_set_no_blocks();
    }
  }
}