You are here

public function SearchPluginBase::suggestedTitle in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/search/src/Plugin/SearchPluginBase.php \Drupal\search\Plugin\SearchPluginBase::suggestedTitle()

Provides a suggested title for a page of search results.

Return value

string The translated suggested page title.

Overrides SearchInterface::suggestedTitle

File

core/modules/search/src/Plugin/SearchPluginBase.php, line 127
Contains \Drupal\search\Plugin\SearchPluginBase.

Class

SearchPluginBase
Defines a base class for plugins wishing to support search.

Namespace

Drupal\search\Plugin

Code

public function suggestedTitle() {

  // If the user entered a search string, truncate it and append it to the
  // title.
  if (!empty($this->keywords)) {
    return $this
      ->t('Search for @keywords', array(
      '@keywords' => Unicode::truncate($this->keywords, 60, TRUE, TRUE),
    ));
  }

  // Use the default 'Search' title.
  return $this
    ->t('Search');
}