1 layout_renderer_editor.inc LayoutRendererEditor::renderBlock($block)

Render a block using its designated style.

This method also manages 'title block' functionality, where the title from an individual block can be bubbled up to take over the title for the entire display.

Parameters

Block $block: The block to be rendered.

Return value

string: The rendered block as HTML.

Overrides LayoutRendererStandard::renderBlock

File

core/modules/layout/plugins/renderers/layout_renderer_editor.inc, line 104
Class file to control the main Layout editor.

Class

LayoutRendererEditor

Code

function renderBlock($block) {
  $aria_label = $this->getAriaLabel($block);
  $buttons = $this->getBlockLinks($block);
  $content = $block->getAdminPreview();

  $attributes = array(
    'tabindex' => '0',
    'aria-label' => $aria_label,
    'class' => array('layout-editor-block clearfix'),
    'id' => 'layout-editor-block-' . $block->uuid,
    'data-block-id' => $block->uuid,
  );

  $block_admin_title = $block->getAdminTitle();
  if (!$block->status) {
    $attributes['class'][] = 'layout-editor-block-disabled';
    $block_admin_title = t('!title (Disabled)', array('!title' => $block_admin_title));
  }

  $output = '<div ' . backdrop_attributes($attributes) . '>';
  $output .= '<div class="layout-editor-block-title clearfix">';
  $output .= '<span class="handle"></span><span class="text">' . $block_admin_title . '</span>';
  if ($buttons) {
    $output .= '<span class="buttons">' . $buttons . '</span>';
  }
  $output .= '</div>'; // layout-block-title
  $output .= '<div tabindex="0" class="layout-editor-block-content">' . render($content) . '</div>';
  $output .= '</div>'; // layout-block

  return $output;
}