public function SearchPluginBase::suggestedTitle in Drupal 9
Same name and namespace in other branches
- 8 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 122
Class
- SearchPluginBase
- Defines a base class for plugins wishing to support search.
Namespace
Drupal\search\PluginCode
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', [
'@keywords' => Unicode::truncate($this->keywords, 60, TRUE, TRUE),
]);
}
// Use the default 'Search' title.
return $this
->t('Search');
}