Alter Views title programmatically on Drupal 8 | Drupal 8

Alter Views title programmatically on Drupal 8

Submitted by editor on Thu, 11/01/2018 - 14:48
Question

How to set title of a views page programmatically ?

function MYMODULE_views_pre_render(ViewExecutable $view) {
 if ($view->id() == 'ABC') {
  $view->setTitle('MY CUSTOM TITLE');
 }
}

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.