Commit 486dc1e0 authored by Navneet Singh's avatar Navneet Singh Committed by Navneet Singh
Browse files

Issue #2853400 by navneet0693, purushotam.rai: Make no results message configurable

parent a5edcdd7
Loading
Loading
Loading
Loading
+1 −7
Changes for google_cse.module: 1 added line, 7 removed lines.
Original line number Diff line number Diff line
@@ -128,11 +128,5 @@ function google_cse_form_search_block_form_alter(&$form, &$form_state, $form_id)
 * @see search_help()
 */
function theme_google_cse_search_noresults() {
  return t('<h2>Sorry there were no results matching your enquiry.</h2>
    <ul>
    <li>Check the spelling of your keywords</li>
    <li>Try a more specific enquiry (e.g. <em>"Penny Black"</em> instead of <em>"Stamps"</em>): "blue drop"</em></li>
    <li>Be explicit (e.g. <em>"Second class stamp"</em> instead of <em>"Stamp"</em>)</li>
    <li>Include spaces between keywords</li>
    </ul>');
  return t(\Drupal::config('search.page.google_cse_search')->get('no_results_message'));
}
+11 −0
Changes for src/Plugin/Search/GoogleCSESearch.php: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ class GoogleCSESearch extends ConfigurableSearchPluginBase implements Accessible
      'results_searchbox_width' => 40,
      'results_display' => 'here',
      'results_display_images' => TRUE,
      'no_results_message' => 'Sorry! there were no results matching your query.',
      'sitesearch' => '',
      'sitesearch_form' => 'radios',
      'sitesearch_option' => '',
@@ -368,6 +369,15 @@ class GoogleCSESearch extends ConfigurableSearchPluginBase implements Accessible
      '#default_value' => $this->configuration['results_display_images'],
    ];

    $form['google_cse']['no_results_message'] = [
      '#title' => $this->t('No Results message.'),
      '#type' => 'textarea',
      '#cols' => 50,
      '#rows' => 4,
      '#description' => $this->t('Enter the message to be displayed when search yield no results.'),
      '#default_value' => $this->configuration['no_results_message'],
    ];

    $form['google_cse']['sitesearch'] = [
      '#title' => $this->t('SiteSearch settings'),
      '#type' => 'details',
@@ -591,6 +601,7 @@ class GoogleCSESearch extends ConfigurableSearchPluginBase implements Accessible
    $this->configuration['results_searchbox_width'] = $values['results_searchbox_width'];
    $this->configuration['results_display'] = $values['results_display'];
    $this->configuration['results_display_images'] = $values['results_display_images'];
    $this->configuration['no_results_message'] = $values['no_results_message'];
    $this->configuration['google_cse_sitesearch'] = $values['google_cse_sitesearch'];
    $this->configuration['sitesearch_form'] = $values['sitesearch_form'];
    $this->configuration['sitesearch_option'] = $values['sitesearch_option'];