Skip to main content
Tweeted twitter.com/StackDrupal/status/1435803681824419847
removed "Drupal" and tags from the title
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

How todo I programmatically set the view title of a views page programmatically?

Source Link
Brian
  • 1.1k
  • 13
  • 29

How to set title of a views page programmatically?

In D8, I have a need to dynamically set the title of a views page display.

I've tried implementing both hook_views_pre_render and hook_views_post_build and setting the value of $view->build_info['title'], but Drupal seems to be ignoring it when setting the page title.

It seems like the code in Views where the title is set is in Drupal\views\Plugin\views\display\Page::execute()

The #title property on the render array in that method IS receiving my overwritten value from one of my hooks, but it's still ignore and is using the manually specified title on the display config.

What is going on!?