Is it possible to change the output created with the Search module? I want to show custom fields, and I want to hide the description, user and date...

  • +1 Good question, what I need to do too, I've provided some comments as to the accepted answer as to the detail that worked for me. – therobyouknow Jan 8 '15 at 10:24

You have two options:

  1. You can use Display Suite module. A sub-module Display Suite Search allows you to change the way nodes are displayed for search results.

  2. You can use template_preprocess_search_result() together with a copy of modules/search/search-result.tpl.php in your theme. Read thoroughly the comments in the search-result.tpl.php as they will help you understand what is going on and what is available to you.
    You can define variables this way: $variables['your_value'] = $variables['result']['node']->field_sample[LANGUAGE_NONE][0]['value']; and use it in the .tpl file like this: print $your_value;.

  • Thanks for this straightforward answer! I'll take a look at this right away! – screaming SiLENCE Oct 19 '12 at 15:19
  • I have all fields available in template_preprocess_search_result(), how do I use them in the .tpl file? Make a global variable? It's working that way, but is that the good way to do things like this? – screaming SiLENCE Oct 19 '12 at 15:57
  • I updated my answer. – Aram Boyajyan Oct 19 '12 at 16:30
  • Thanks mate, I loved Drupal before, and I'm loving it more and more, and a bit of the honour goes to you ;) – screaming SiLENCE Oct 20 '12 at 8:23
  • You are welcome. Glad I helped. – Aram Boyajyan Oct 22 '12 at 16:07

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.