Linked Questions

5 votes
4 answers
6k 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 <...
-1 votes
1 answer
682 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
1 answer
595 views

Is there a way to get the controller class from a Request object or any other service class?

My controller class holds some not-so-easy logic to receive some data from a route parameter I need in a block plugin. As this block will only be rendered on this specific route, I would like to ...
7 votes
4 answers
13k 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 ...
0 votes
1 answer
181 views

How do I identify what type of data or object I have? It's a referenced entity

I am new to Drupal but an experienced developer. I'm creating a DS field in which I will display a custom block chosen by the content editor. I have successfully gotten a referenced entity (two ...
2 votes
3 answers
15k views

Render a custom block programmatically [duplicate]

How do I render a custom block type (block_content) programmatically with a specific display view?
1 vote
3 answers
2k 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
1 answer
2k 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
1 answer
2k 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 ...
3 votes
2 answers
5k 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
1 answer
6k 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 ...
5 votes
2 answers
9k 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) { $...
-1 votes
1 answer
29 views

Altering block to include another block

I am using the following code for a block. public function build() { $current_client = \Drupal::service('user.private_tempstore')->get('epensions'); $build = []; $build['client'] = ...
0 votes
2 answers
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
1 answer
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 ...

15 30 50 per page