Entity Parser with twig extension
Last updated on
13 June 2018
Node Parser for twig
{% set options ={'#entity_parser_extend':'Drupal\\entity_parser_demo\\EntityParserDemo'} %}
{% set fields = {1:'body',2:'title'} %}
{% set node_array = node_parser(content,fields,options)%}
<div class='title'>{{node_array.title}}</div>
<div class='body'>{{node_array.body|first.summary}}</div>
Block content Parser for twig
if you create a custom block call : "test" in backend url : www.domain.com/block/add , then you want to handle the block content in block--test.html.twig
{% set options = {'#entity_parser_extend':'Drupal\\entity_parser_demo\\EntityParserDemo'} %}
{% set fields = {} %} {# make empty for getting all fields #}
{% set block_content_array = (block_parser(content,fields,options)) %}
<div>(block_content_array.body|first).summary</div>
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion