0

I want to remove dots from search results items descriptions to search result page ( Default Search ), i have used Drupal default search for the search result page so how to remove the dots from the search descriptions.

I tried with search and replace function using theme preprocess search result function but no luck.

theme_preprocess_search_result()

enter image description here

function theme_preprocess_search_result(&$variables) {

  $variables['search_excerpt'] = str_replace("...", "", $variables['snippet']['#markup']);

}

But it's not work as expected,if have any solution please put into comment.

Thanks in advance.

1

You use incorrect variable name.

Take a look for the search-result.html.twig template. We have a snippet template variable.

Your code should looks like:

function theme_preprocess_search_result(&$variables) {
  $variables['snippet']['#markup'] = str_replace('…', '', $variables['snippet']['#markup']);
}

Pay attention to …, this is a special symbol, not ... (three dots).

| improve this answer | |
  • Thanks @ivan Tibezh.. It is working now. – Hims V May 13 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.