After successful integration of apache solr module in drupal 7 and displaying the result Ii found that it is using the view files (search-results.tpl.php & search-result.tpl.php) from the core search module to display the result.

How can I use my custom files similar to (search-results.tpl.php & search-result.tpl.php) inside the apache solr module folder to display the result?

Since I am new to drupal and just started can somebody guide me to implement it.

  • Do you want to build a view for apachesolr? Sep 20, 2012 at 9:22
  • @ Mathankumar yes i want to build new view for apache solr
    – oldrock
    Sep 21, 2012 at 12:33
  • Then you can use apachesolr views module Sep 21, 2012 at 13:33

2 Answers 2


Copy the search-results.tpl.php & search-result.tpl.php into your theme folder. Drupal will then use these files instead of the core. If you want to pass extra variables to the search-result you can use hook_preprocess_search_result

function mymodule_preprocess_search_result(&$variables){
    $variables['myvariable'] = 'this is a variable pass to the search-result.tpl.php';

and then access your variables from within search-result.tpl.php like

print ('My variable: '.$myvariable);

This is a duplicate of the question https://stackoverflow.com/questions/12496764/how-to-build-my-own-view-for-apache-solr-module so the answer is the same as well. Let me quote:

The .tpl.php files are theme template files, and you can override them by using identically named files in your own theme. Some deeper reading at Drupal docs.

Or you could use the search features provided by Google, as I did, and find an already existing answer on a related site.

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.