$view = views_get_view('[VIEW_NAME]');
$view->set_display('[DISPLAY_ID]');
$view->display_handler->set_option('title', '[NEW_TITLE]');
$view->save();
- Add new comment
- 738 views
$view = views_get_view('[VIEW_NAME]');
$view->set_display('[DISPLAY_ID]');
$view->display_handler->set_option('title', '[NEW_TITLE]');
$view->save();
Comment
How do I programmatically render a view with contextual filters
Submitted by TS (not verified) on Thu, 10/25/2018 - 07:32
// Drupal 7
$view = views_get_view('[VIEW_NAME]');
$view->set_arguments($tid);
$view->set_display("[DISPLAY_ID]");
$view->pre_execute();
$view->execute();
$content = $view->render();
// Drupal 8
$args = [$tid];
$view = Views::getView('[VIEW_NAME]');
if (is_object($view)) {
$view->setArguments($args);
$view->setDisplay('[DISPLAY_ID]');
$view->preExecute();
$view->execute();
$content = $view->buildRenderable('[DISPLAY_ID]', $args);
}