Created
April 19, 2024 05:13
-
-
Save alokstha1/0c43b081d0a2e70ab376b0ff0a214e86 to your computer and use it in GitHub Desktop.
Load a view of a FIELD type for a profile in Drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Drupal\node\Entity\Node; | |
use Drupal\taxonomy\Entity\Term; | |
use Drupal\views\ViewExecutable; | |
use Drupal\views\Views; | |
use Drupal\Core\Render; | |
$nid = 1; | |
$entity_type = 'node'; | |
$view_mode = 'teaser'; | |
$builder = \Drupal::service('entity_type.manager')->getViewBuilder($entity_type); | |
$storage = \Drupal::service('entity.manager')->getStorage($entity_type); | |
$node = $storage->load($nid); | |
$build = $builder->view($node, $view_mode); | |
$output = \Drupal::service('renderer')->render($node); | |
var_dump($node); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment