Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $block = module_invoke('block', 'block_view', '4');
- $text_block = render($block['content']);
- $bid = ??? // Get the block id through config, SQL or some other means
- $block = Drupalblock_contentEntityBlockContent::load($bid);
- $render = Drupal::entityTypeManager()->
- getViewBuilder('block_content')->view($block);
- return $render;
- $block_manager = Drupal::service('plugin.manager.block');
- // You can hard code configuration or you load from settings.
- $config = [];
- $plugin_block = $block_manager->createInstance('system_breadcrumb_block', $config);
- // Some blocks might implement access check.
- $access_result = $block_plugin->access(Drupal::currentUser());
- // Return empty render array if user doesn't have access.
- if ($access_result->isForbidden()) {
- // You might need to add some cache tags/contexts.
- return [];
- }
- $render = $plugin_block->build();
- // In some cases, you need to add the cache tags/context depending on
- // the block implemention. As it's possible to add the cache tags and
- // contexts in the render method and in ::getCacheTags and
- // ::getCacheContexts methods.
- return $render;
- $block = DrupalblockEntityBlock::load('config.id');
- $render = Drupal::entityTypeManager()
- ->getViewBuilder('block')
- ->view($block);
- return $render;
- $block = DrupalblockEntityBlock::load('my_block_id');
- $variables['My_region'] = Drupal::entityManager()
- ->getViewBuilder('block')
- ->view($block);
- {% if page.My_region %}
- {{ page.My_region }}
- {% endif %}
- public function content() {
- $block = DrupalblockEntityBlock::load('my_block_id');
- $block_content = Drupal::entityManager()
- ->getViewBuilder('block')
- ->view($block);
- return array(
- '#type' => 'container',
- '#attributes' => array(
- 'class' => array("Myclass"),
- ),
- "element-content" => $block_content,
- '#weight' => 0,
- );
- }
- $con = DrupalblockBlockViewBuilder::lazyBuilder('bartik_search', 'full');
- $d = Drupal::service('renderer')->renderPlain($con);
- print $d->__toString();
- // You need a block_id! to get it just click configure in the desire block and you'll get url like this /admin/structure/block/manage/bartik_search the last part of the parameter is the block id
- $block = DrupalblockEntityBlock::load('bartik_search');
- $block_content = Drupal::entityManager()
- ->getViewBuilder('block')
- ->view($block);
- return array('#markup' => drupal_render($block_content));
- $view = views_embed_view('my_view_name', 'my_display_name');
- return [
- ['description' => [
- '#theme' => 'your_theme_hook',
- '#your_variable => $view
- ]
- ]
- function hook_theme($existing, $type, $theme, $path) {
- return array(
- 'your_theme_hook' => array(
- 'variables' => [
- 'your_variable' => NULL,
- ]
- )
- )
- }
- {{ your_variable }}
- return array('#markup' => drupal_render($block_content));
- $block = DrupalblockEntityBlock::load ('my_bock_id');
- $block_content = Drupal::entityManager ()->
- getViewBuilder ('block')->
- view ($block);
- return array (
- '#type' => 'container',
- 'element-content' => $block_content
- );
- return ['#markup' => Drupal::service ('renderer')->render ($block_content)];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement