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 Answer
You have two options:
You can use Display Suite module. A sub-module Display Suite Search allows you to change the way nodes are displayed for search results.
You can use
template_preprocess_search_result()
together with a copy ofmodules/search/search-result.tpl.php
in your theme. Read thoroughly the comments in thesearch-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! Oct 19, 2012 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? Oct 19, 2012 at 15:57
-
-
Thanks mate, I loved Drupal before, and I'm loving it more and more, and a bit of the honour goes to you ;) Oct 20, 2012 at 8:23
-