1

I have created a views block in D8 and thinking to embed it within a particular custom block template I created to override (e.g block--myblock.html.twig), I wonder how to do this ?

1 Answer 1

0

Ok, I have found a way to do so from another post, tested and it works ! So basically..

1) Create a new variable in mytheme.theme file located in your default theme folder.

function mytheme_preprocess_block(&$variables) {

  $variables['view1'] = views_embed_view('view_name', 'block_news');

}

'block_news' is your views block's machine name actually.

2) And then use this twig in your block template.

 {{ view1 }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.