function ViewPageController::getTitle

Same name in other branches
  1. 10 core/modules/views/src/Routing/ViewPageController.php \Drupal\views\Routing\ViewPageController::getTitle()
  2. 11.x core/modules/views/src/Routing/ViewPageController.php \Drupal\views\Routing\ViewPageController::getTitle()

Gets the title of the given view's display.

Parameters

string $view_id: The id of the view.

string $display_id: The id of the display from the view.

Return value

string|\Drupal\Component\Render\MarkupInterface The title of the display of the view.

File

core/modules/views/src/Routing/ViewPageController.php, line 80

Class

ViewPageController
Defines a page controller to execute and render a view.

Namespace

Drupal\views\Routing

Code

public function getTitle($view_id, $display_id = 'default') {
    $view = Views::getView($view_id);
    $view->setDisplay($display_id);
    return ViewsRenderPipelineMarkup::create(Xss::filter($view->getTitle()));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.