Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. function mymodule_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  2.  
  3. if ($entity->getEntityType()->id() == 'node' && $entity->bundle() == 'example_content_type') {
  4. $node_id = Drupal::routeMatch()->getRawParameter('node');
  5. $index = 0;
  6. foreach($build['field_paragraph_field'] as $key => $value) {
  7.  
  8. if (is_numeric($key) && $value['#paragraph']->bundle() == 'body') {
  9. $news_view = [
  10. '#type' => 'view',
  11. '#name' => 'my_news_feed',
  12. '#display_id' => 'block_1',
  13. '#arguments' => [$node_id],
  14. ];
  15.  
  16. array_splice($build['field_paragraph_field'], $index + 1, 0, [$news_view]);
  17.  
  18. }
  19. $index++;
  20. }
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement