Customizing search results, hidden treasures

Drupal has built-in search functionality, and for the most part? It works just fine out of the box. The pain starts when clients ask for customization in the results page -- and a lot of it. After reading a nuber of posts on the net, I finally found a bit that others seem to ignore: you get a whole lot of info in the search result template.

First, the basics. If you want to touch the search page, you should copy over the two templates responsible for that output into your current theme ( you can find these in /modules/search ); namely, search-results.tpl.php and search-result.tpl.php . Note the bolded 's' -- that's the template that simply puts the individual results together, while the other themes each result.

Editing the template you will find a docblock with the variables available -- however, the glaring omission ( and the reason behind this article ), is the $result variable, which holds a ton of date. The main thing you will want to access is hidden in $result['node'] which is (surprise!) a fully populated node object.

You can then easily use CCK fields, or even dates, teasers, as you would in any other template.