Skip to main content
3 of 3
edited tags
4uk4
  • 101.7k
  • 7
  • 173
  • 217

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?

mogio
  • 697
  • 7
  • 27