Skip to main content
edited tags
Link
4uk4
  • 101.7k
  • 7
  • 173
  • 217
removed tags from the title
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

D8 - Create RenderArray of Field

Source Link
mogio
  • 697
  • 7
  • 27

D8 - Create RenderArray of Field

In my theme_preprocess_taxonomy_term function I am loading a node. Then want to move its "body field" to the content array of my template.

    mytheme_preprocess_taxonomy_term(&$variables){
        $import_content_node_id = 32;
        //load node
        $import_content_node = $node = Node::load($import_content_node_id);
        variables['content']['body'] = $import_content_node->getFields()['body'];
}

This does not work because variables['content']['body'] is NOT a render array.

But from where I get the render array? Or how do I create one from an by script loaded node?