Search result to show link to the page not to the pdf file I am using the Search file attachments module (which searches for text from pdf files after they are indexed), and everything works fine.

But I would like in Search result to display link to the content (where I uploaded the file) not link to the PDF itself, so that the user goes to that page and from there he can choose to see the PDF.

I am still new to Drupal, but from what I have read that I have to alter $search_results in search-results.tpl.php and use template_preprocess_search_results() to display what I want (not sure if this is the right way) or is there another way to this?

EDIT:

I found that I could edit search_file_attacments.module and there is the link attribute in $results[] I just have to figure out how to get nid (so I can get the url) from fid
First, I can't install the Search File Attachments module at this moment, but you can read at the module's page:


  The module is based on the core search and no other module is
  required.


And I don't see any template page inside the module.

As in the search-result.tpl.php you will only have access to the $snippet variable, this is not a solution for you, because $snippet is a string, see the code inside search-result.tpl.php:

&lt;?php if ($snippet): ?&gt;
  &lt;p class="search-snippet"&lt;?php print $content_attributes; ?&gt;&gt;&lt;?php print $snippet; ?&gt;&lt;/p&gt;
&lt;?php endif; ?&gt;


So your best bet should be implement the template_preprocess_search_results() in the template.php file of your theme.

See this example:

function THEME_preprocess_search_result(&amp;$variables) {
    dpm($variables); //you need devel module to use dpm
}


Inside $variables['result'] you will have the values that you need to make your modification. See the dpm() output:



If you want modify the $snippet variable then change the value inside the function like this:

function THEME_preprocess_search_result(&amp;$variables) {
  //searching the info that you need
  $variables['snippet'] = 'The new value';
}