Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. $block = module_invoke('block', 'block_view', '4');
  2. $text_block = render($block['content']);
  3.  
  4. $bid = ??? // Get the block id through config, SQL or some other means
  5. $block = Drupalblock_contentEntityBlockContent::load($bid);
  6. $render = Drupal::entityTypeManager()->
  7. getViewBuilder('block_content')->view($block);
  8. return $render;
  9.  
  10. $block_manager = Drupal::service('plugin.manager.block');
  11. // You can hard code configuration or you load from settings.
  12. $config = [];
  13. $plugin_block = $block_manager->createInstance('system_breadcrumb_block', $config);
  14. // Some blocks might implement access check.
  15. $access_result = $block_plugin->access(Drupal::currentUser());
  16. // Return empty render array if user doesn't have access.
  17. if ($access_result->isForbidden()) {
  18. // You might need to add some cache tags/contexts.
  19. return [];
  20. }
  21. $render = $plugin_block->build();
  22. // In some cases, you need to add the cache tags/context depending on
  23. // the block implemention. As it's possible to add the cache tags and
  24. // contexts in the render method and in ::getCacheTags and
  25. // ::getCacheContexts methods.
  26. return $render;
  27.  
  28. $block = DrupalblockEntityBlock::load('config.id');
  29. $render = Drupal::entityTypeManager()
  30. ->getViewBuilder('block')
  31. ->view($block);
  32. return $render;
  33.  
  34. $block = DrupalblockEntityBlock::load('my_block_id');
  35. $variables['My_region'] = Drupal::entityManager()
  36. ->getViewBuilder('block')
  37. ->view($block);
  38.  
  39. {% if page.My_region %}
  40. {{ page.My_region }}
  41. {% endif %}
  42.  
  43. public function content() {
  44. $block = DrupalblockEntityBlock::load('my_block_id');
  45. $block_content = Drupal::entityManager()
  46. ->getViewBuilder('block')
  47. ->view($block);
  48.  
  49. return array(
  50. '#type' => 'container',
  51. '#attributes' => array(
  52. 'class' => array("Myclass"),
  53. ),
  54. "element-content" => $block_content,
  55. '#weight' => 0,
  56. );
  57. }
  58.  
  59. $con = DrupalblockBlockViewBuilder::lazyBuilder('bartik_search', 'full');
  60. $d = Drupal::service('renderer')->renderPlain($con);
  61. print $d->__toString();
  62.  
  63. // 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
  64. $block = DrupalblockEntityBlock::load('bartik_search');
  65. $block_content = Drupal::entityManager()
  66. ->getViewBuilder('block')
  67. ->view($block);
  68.  
  69. return array('#markup' => drupal_render($block_content));
  70.  
  71. $view = views_embed_view('my_view_name', 'my_display_name');
  72.  
  73. return [
  74. ['description' => [
  75. '#theme' => 'your_theme_hook',
  76. '#your_variable => $view
  77. ]
  78. ]
  79.  
  80. function hook_theme($existing, $type, $theme, $path) {
  81. return array(
  82. 'your_theme_hook' => array(
  83. 'variables' => [
  84. 'your_variable' => NULL,
  85. ]
  86. )
  87. )
  88. }
  89.  
  90. {{ your_variable }}
  91.  
  92. return array('#markup' => drupal_render($block_content));
  93.  
  94. $block = DrupalblockEntityBlock::load ('my_bock_id');
  95. $block_content = Drupal::entityManager ()->
  96. getViewBuilder ('block')->
  97. view ($block);
  98.  
  99. return array (
  100. '#type' => 'container',
  101. 'element-content' => $block_content
  102. );
  103.  
  104. return ['#markup' => Drupal::service ('renderer')->render ($block_content)];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement