0

I am trying to create a custom page that display my resuslts which I receive after I search for a post.

I am having no luck, I am a total begginer in drupal 7, I googled and looked around here but I did not quite understood what I have to do.

What I tried:

function **themename**_preprocess_search_results(&$variables) {
  $variables['search_results'] = '';
  if (!empty($variables['module'])) {
    $variables['module'] = check_plain($variables['module']);
  }
  foreach ($variables['results'] as $result) {
    $variables['search_results'] .= theme('search_result', array('result' => $result, 'module' => $variables['module']));
  }
  $variables['pager'] = theme('pager', array('tags' => NULL));
  $variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module'];
}
  1. Creating a search-results.tpl.php ( did not work )
  2. The only module I have installed for search is the default search module.

Nothing seems to work. Thanks in advance

1
  • search-results.tpl.php should be search--results.tpl.php. Two dashes, not one
    – Clive
    Commented Dec 19, 2017 at 14:11

1 Answer 1

-1

You are just processing the search results in your function but haven;t handled the output. Change the tpl.php to display the variables from your function rather than from the default search function.

1
  • $variables['search_results'] does contain the output. It is used from the template file. I am not sure what you mean by but haven't handled the output. May you make that clearer?
    – avpaderno
    Commented Dec 19, 2017 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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