Access node from a block

by paulcap1   Last Updated December 15, 2017 14:07 PM

I am using Drupal Lightning and a bootstrap subtheme. I need to print a nodes fields in a block. Example my page node has fields

{{ node.title.value }}
{{ content.field_text }}

It also has an includes template

{% include '@mytheme/includes/section.html.twig' %}

I can print these fields fine in a node template

node--page.html.twig

But now I need to print these fields outside of the node template and into a block. I tried to create a View block and set a contextual filter "Content ID from URL" THen placed the View block in a region and then in the region template I tried to access the node fields from my region template but could not.

region--topcontent.html.twig

I then tried Entity blocks. I created a new block of type Entity view (Content). I tried to access the node fields from my region template but could not.

block--entityviewcontent.html.twig
Tags : 8 theming entities


Related Questions



Passing reference to drupal_render()?

Updated August 07, 2017 13:07 PM

Print content from referencing entity on node page

Updated August 27, 2017 12:07 PM

How to display custom data array via Twig

Updated May 29, 2016 08:03 AM