How to use Entity Parser
Last updated on
1 April 2021
- Node Parser :
$nid = 84;
$parser = new Drupal\entity_parser\EntityParser();
$node_array = $parser->node_parser($nid);
//output result
print $node_array['body'][0]['summary']
print $node_array['title']
print $node_array['image']['url'] // full image path - Node Parser with fields filter
$nid = 84;
$parser = new Drupal\entity_parser\EntityParser();
$fields =['title','body','image']; // specify the fields you want get
$node_array = $parser->node_parser($nid,$fields,$options);
//output result
print $node_array['body'][0]['summary']
print $node_array['title']
print $node_array['image']['url'] // full image path - Taxonomy parser
$tid = 4;
$parser = new Drupal\entity_parser\EntityParser();
$term_array = $parser->taxonomy_term_parser($tid);
//output result
print $term_array['name']
print $term_array['tid'] - User Parser
$uid = 5;
$parser = new Drupal\entity_parser\EntityParser();
$user_array = $parser->user_parser($uid);
//output result
print user_array['email'] - Block Content Parser
$block_id = 5;
$parser = new Drupal\entity_parser\EntityParser();
$block_array = $parser->block_parser($block_id);
//output result
print $block_array['body'] 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