Linked Questions

0 votes
0 answers
64 views

Render custom block in template file [duplicate]

I want render my custom block in template file, but what I get is the block without going through the twig file. theme_preprocess_page(&$variables) { $block = \Drupal::service('plugin....
BOES's user avatar
  • 1,023
0 votes
0 answers
29 views

Get the breadcrumb inside my node template [duplicate]

How can I move my breadcrumb from my page.html.twig into my node--content-type.html.twig ? In my page template, I display the breadcrumb like this : <div id="main-wrapper" class="...
user avatar
10 votes
6 answers
22k views

How do I programmatically place a block?

From UI you can add a block in a region in that way: Go to Admin -> Structure -> Block layout (/admin/structure/block). Click on "Place block" button besides the region name. I want to do the ...
user3554770's user avatar
7 votes
2 answers
8k views

How can I access the main menu in template_preprocess_page?

I would like to assign the main menu of my site to a variable using template_preprocess_page() so that I can just use something like {{main_menu}} in the page template. Any ideas on how I would go ...
Janey's user avatar
  • 1,290
2 votes
2 answers
9k views

How do I print core block or views block in node.html.twig?

I'm pretty new to D8, so this might be basic stuff, but I can't find any tutorial how to do it. In Drupal 7 this is the code that outputs core block in node.tpl.php: <?php $block = module_invoke('...
take2's user avatar
  • 234
5 votes
2 answers
3k views

How do I add a custom block to a view?

In preset views like the Taxonomy Term one (/taxonomy/term/%), it can be done by adding a custom block to the footer, but it is not controllable as block layout on /admin/structure/block. Is it ...
Tomotsugu Kaneko's user avatar
4 votes
1 answer
4k views

How to render a facet block?

I've created a facet block according to this example Programatically render a block in a twig template I've created the facet block as follows: $variables['block_output'] = Drupal::service('plugin....
marco-s's user avatar
  • 473
1 vote
3 answers
5k views

Programmatically loading Custom block in page/node preprocessor

I've followed some previous solutions on DA to programmatically load a Custom block in my page preprocessor hook but nothing I try seems to be working. Currently, my custom block is within Structure >...
John Cogan's user avatar
1 vote
1 answer
989 views

Block Regions in node.html.twig

How can i use block regions in my node.html.twig in drupal 8 ? i tried this : block_get_blocks_by_region but function not found
Sina Miandashti's user avatar
0 votes
1 answer
657 views

Get rendered content of one block created as derivative block

I have created derivative blocks using a method such as this and want to get the contents of a specific derivative block. I can see all the available blocks (even derivative blocks) that have been ...
GiorgosK's user avatar
  • 8,523
1 vote
1 answer
137 views

Loading views blocks that aren't actively set

Is there a way to programmatically load a views block that isn't active in the config(not placed under admin->structure->block layout). My usual method to load a block programmatically is something ...
gcalex5's user avatar
  • 166
0 votes
1 answer
78 views

How do I place a block in a region, programatically?

Why isn't my custom block rendering in the region I want? It shows in the content region, not my custom content_right region. function bootstrap_preprocess_html(&$variables) { if (\Drupal::...
user avatar
1 vote
1 answer
31 views

Content type / block or page .. how do we create a small text for a page in D8

Let's say, I have a footer where I want to show a simple text not menu or link just a simple block of text. So, since it's neither a page, an article or block ... is there any way to create a text and ...
hidar's user avatar
  • 139
0 votes
0 answers
49 views

Setting visibility by content type while adding block to region from code

I created block from code. Now I want to add it to specific region ('sidebar_first') also from code. I'm doing it like this: function event_block_preprocess_page(&$vars) { if (\Drupal\block\...
MilanG's user avatar
  • 569