diff --git a/core/modules/search/lib/Drupal/search/Controller/SearchController.php b/core/modules/search/lib/Drupal/search/Controller/SearchController.php index 83ca3b5..b40e11b 100644 --- a/core/modules/search/lib/Drupal/search/Controller/SearchController.php +++ b/core/modules/search/lib/Drupal/search/Controller/SearchController.php @@ -65,10 +65,13 @@ public function view(Request $request, SearchPageInterface $entity, $keys = '') $keys = $request->query->get('keys'); } $keys = trim($keys); - $build['#title'] = $this->t('Search'); $plugin = $entity->getPlugin(); $plugin->setSearch($keys, $request->query->all(), $request->attributes->all()); + + //create page title. + $build['#title'] = $plugin->suggestedTitle(); + // Default results output is an empty string. $results = array('#markup' => ''); diff --git a/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php b/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php index c473838..506307f 100644 --- a/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php +++ b/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php @@ -96,4 +96,14 @@ public function buildResults(); */ public function searchFormAlter(array &$form, array &$form_state); + /** + * Provides a suggested title for a page of search results. Title suggestion + * should be translated. + * + * @return string + * The suggested page title. + */ + public function suggestedTitle(); + + } diff --git a/core/modules/search/lib/Drupal/search/Plugin/SearchPluginBase.php b/core/modules/search/lib/Drupal/search/Plugin/SearchPluginBase.php index ec808ad..b7ba988 100644 --- a/core/modules/search/lib/Drupal/search/Plugin/SearchPluginBase.php +++ b/core/modules/search/lib/Drupal/search/Plugin/SearchPluginBase.php @@ -102,4 +102,15 @@ public function searchFormAlter(array &$form, array &$form_state) { // Empty default implementation. } + /** + * {@inheritdoc} + */ + public function suggestedTitle() { + $title = $this->t('Search'); + //If keywords are passed, append them to the title. + if (!empty($this->keywords)) { + $title .= ' ' . $this->keywords; + } + return $title; + } }