You are here

function _panopoly_widgets_is_title_shown in Panopoly Widgets 7

Determines if the given view mode on this node shows the title.

Parameters

object $node: The fully loaded node object to check.

string $view_mode: The view mode.

Return value

boolean TRUE if the title is shown; FALSE otherwise.

1 call to _panopoly_widgets_is_title_shown()
panopoly_widgets_views_post_execute in ./panopoly_widgets.module
Implements hook_views_post_execute().

File

./panopoly_widgets.module, line 679

Code

function _panopoly_widgets_is_title_shown($node, $view_mode) {
  if (!empty($node->panelizer) && (!empty($node->panelizer[$view_mode]) || !empty($node->panelizer['default']))) {
    $panelizer_display = isset($node->panelizer[$view_mode]) ? $node->panelizer[$view_mode]->display : $node->panelizer['default']->display;
    if (empty($panelizer_display->hide_title) && empty($panelizer_display->pane_title) && strpos($panelizer_display->title, '%node:title') !== FALSE) {

      // We're showing the title via the Panelizer display title.
      return TRUE;
    }
    else {
      foreach ($panelizer_display->content as $pane) {
        if ($pane->type == 'node_title' && $pane->subtype == 'node_title' || $pane->type == 'token' && $pane->subtype == 'node:title') {

          // We're showing the node title in a Pane inside the view mode.
          return TRUE;
        }
        elseif ($pane->type == 'node_content' && $pane->subtype == 'node_content') {
          $child_view_mode = $pane->configuration['build_mode'];

          // Prevent endless recursion.
          if ($child_view_mode == $view_mode) {
            if ($child_view_mode != 'full') {
              $child_view_mode = 'full';
            }
            else {
              continue;
            }
          }
          if (_panopoly_widgets_is_title_shown($node, $child_view_mode)) {
            return TRUE;
          }
        }
      }
      return FALSE;
    }
  }
  else {

    // If we're not using Panelizer, the theme should always be showing
    // the title when rendering the node.
    return TRUE;
  }
}