Linked Questions

2
votes
3answers
11k views

Render a custom block programmatically [duplicate]

How do I render a custom block type (block_content) programmatically with a specific display view?
5
votes
4answers
9k views

Place a block inside a twig template

I've got a custom content type 'professor', and a 'node--professor.html.twig' in my theme (derived from 'classy') to override the standard markup. The designer wants me to put a list (a view?) of the ...
5
votes
2answers
5k views

Programmatically accessing block content

Could anyone tell me how to programmatically access the field content of a custom block? Thus far I've managed: use Drupal\block\Entity\Block; $block = Block::load($block_name); if ($block) { $...
4
votes
3answers
3k views

How to get the context node in a custom block inside a views list?

I have a view which displays all pictures of the content type photo. I've set some fields in this view for the display. This is how iIrender the list of pictures: views-view-fields--photo.html <...
2
votes
2answers
2k views

Render custom block using block.html.twig template

I'm attempting to render a custom content block programmatically (created through the Custom Block Library UI) and I would like the block to render using block.html.twig as it would if I were to place ...
5
votes
1answer
3k views

Use a twig template instead of a render array in a custom module admin page

I have a Drupal 8 custom module, and I want to display its configuration page using the admin theme. Usually, for this kind of pages I use, in the _controller property of my route, rather : a class ...
0
votes
2answers
4k views

Render blocks in custom page

I followed steps given in this link to create a custom Page. Page is created and 'Hello world' is printing in the page, now i want to render some blocks in that page. How can I achieve this task?
0
votes
1answer
2k views

D8: render block in node?

We're migrating some code to D8 and in some of our nodes' body field we used to call PHP code directly with the now defunct module_invoke to render a block in the node before the content. All the ...
1
vote
3answers
964 views

How to place facet block in views page header? (not regions)

I've created a search with Search API module and Facets module. I've added two taxonomy term name fields to my search index and created two facets for those fields. Just for testing I've placed the ...
2
votes
1answer
1k views

Can't render a block due to recoverable fatal error

I had code to programmatically render a block. $block = \Drupal\block\Entity\Block::load('bartik_search'); $block_content = \Drupal::entityManager() ->getViewBuilder('block') ->view($block);...
0
votes
1answer
1k views

how to know block id in class which extend from BlockBase

I am trying to get block id in my custom module in build function of class which extends BlockBase. How can i do this? i want to use this block_id in another class controller to have configuration ...
0
votes
2answers
1k views

Custom blocks created as a plugin in a module not showing for Block::load()

I have a couple of blocks that have been created using the ... extends BlockBase syntax in my module. They work perfectly fine, and I can add them on the blocks layout page, can add them into DS as a ...
1
vote
0answers
485 views

Programmatically creating mulitple blocks without creating seperate .php files for them

EDIT: The code below works - there was a problem with my local machine - read more at the end for why it did not work I want to create multiple blocks that don't need custom setttings from the ...
0
votes
1answer
443 views

How to print Blocks in commerce-product.html.twig

I am looking at building a Drupal 8 Commerce 2 product display through twig but I am having issues with how to print custom blocks in this template file. (And also testing these in normal page.html....
0
votes
1answer
150 views

blocks are null on admin theme [duplicate]

I made a sub-theme of the admin theme "Seven" and called it Seven2 Because I wanted to customize the node-edit-form.twig.html file. That works. My next step, I want to add a block I made in a custom ...

15 30 50 per page