I am using Apache Solr Search on my site, and would like links on the search results page to open in a new window/tab. How can I accomplish this?

  • Welcome to Drupal Answers. I edited this to reflect the comment below. No need to ask a new question.
    – mpdonadio
    Sep 4 '13 at 21:05

You should install Custom Search module as it does provide an option to open results in new tab or lightbox.


Otherwise you can always look into using custom functions or js to achieve the same in your search template.

Updated Answer

Since you are using solr and search-result.tpl.php you should have a line like:

<a href="<?php print $url; ?>"><?php print $title; ?></a>

change it by adding target value like:

<a href="<?php print $url; ?> target='_blank'><?php print $title; ?></a>
  • Thanks for the quick response but I am already using a Apache solr search so wanted to know how to edit the search!
    – bashres
    Sep 4 '13 at 20:55
  • Are you using search-result.tpl.php?
    – pgrujic
    Sep 4 '13 at 20:58
  • Yes I am using it.
    – bashres
    Sep 4 '13 at 21:05
  • Thanks.Is there anyway we could do by using Hook?
    – bashres
    Sep 4 '13 at 23:36
  • Yes you can do it via hook in either custom module or in template file.
    – pgrujic
    Sep 5 '13 at 11:30

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.