Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save algotrader-dotcom/880f84a97aad1e858379bad5e464d9d4 to your computer and use it in GitHub Desktop.

Select an option

Save algotrader-dotcom/880f84a97aad1e858379bad5e464d9d4 to your computer and use it in GitHub Desktop.
Drupal 8 : Render view programmatically
<?php
$id = 'a';
$view = \Drupal\views\Views::getView('glossary');
$view->setDisplay('default');
$view->setArguments([$id]);
$view->execute();
$results = $view->result;
foreach($results as $result){
$nid = $result->nid;
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
$node = $node_storage->load($nid);
print $node->title->value."\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment