public static function WeMegaMenuBuilder::renderBlock in Drupal Mega Menu 8.x
Same name and namespace in other branches
- 8 src/WeMegaMenuBuilder.php \Drupal\we_megamenu\WeMegaMenuBuilder::renderBlock()
Render drupal block.
Parameters
string $bid: Public static function renderBlock bid.
bool $title_enable: Public static function renderBlock title_enable.
string $section: Public static function renderBlock section.
Return value
string [markuphtml] Public static function renderBlock string.
1 call to WeMegaMenuBuilder::renderBlock()
- template_preprocess_we_megamenu_col in ./we_megamenu.module 
- Prepare variables for we_megamenu_col.
File
- src/WeMegaMenuBuilder.php, line 241 
Class
Namespace
Drupal\we_megamenuCode
public static function renderBlock($bid, $title_enable = TRUE, $section = '') {
  $html = '';
  if ($bid && !empty($bid)) {
    $block = Block::load($bid);
    if (isset($block) && !empty($block)) {
      $title = $block
        ->label();
      $block_content = Drupal::entityTypeManager()
        ->getViewBuilder('block')
        ->view($block);
      if ($section == 'admin') {
        $html .= '<span class="close icon-remove" title="Remove this block"> </span>';
      }
      $html .= '<div class="type-of-block">';
      $html .= '<div class="block-inner">';
      $html .= $title_enable ? '<h2>' . $title . '</h2>' : '';
      $html .= render($block_content);
      $html .= '</div>';
      $html .= '</div>';
    }
    else {
      $html = '<p><b>Warning:</b> <i>Broken/Missing block</i></p>';
    }
  }
  return $html;
}