Is it possible to do that ?
I like your module because is the only one which can search inside cck filefield files right now.
But I use views exposed filters for searching instead of standard core search feature and without merging there is no possibility to search inside files by filter.

And one more think I found out when testing your module. The option to show ONLY title linked to node instead of title/filename linked to file.

ps. nice interview on drupal voices. i agree with documentation importance. i'am not a coder but even me started to documenting my last drupal project after i realised that i dont remember what each rule or view or nodereference field was for... :) maybe funny but true.

thanks

Comments

jhodgdon’s picture

Title: Merge with drupal core search » Display node title/link in results, as an option, not including file name/link

OK, I think you have two completely different feature requests here.

a) It is not possible, even as a feature request, to merge search results from Search by Page directly in with the node search results provided by core search. You can only display the search results on a different tab. So it won't merge with Views searching by keyword. Sorry. There's just no way to do this within the framework of what Search by Page does.

It would be possible to write a completely different module that interfaced with node search in that way. What you would need to do is to use hook_nodeapi and when the node is being rendered for search indexing, add the contents of the file to the rendered node. But that would be outside the scope of Search by Page.

b) I think you are requesting the option in Search by Page Attachments to have another display option where you would display a link to the node instead of a link to the filename, with the link title being the node title and not including the file name or the description. This is possible, so I'm changing the title of this issue to request this as a feature.

benone’s picture

Great, thanks for that. Having this option would be fantastic as I dont want users to download PDF file, just go to the node and view it from the node content using swftools/flexpaper.
This is great. When you think you will be able to add this feature ?

Do you have any idea how to get searching possibile within views ?
I use exposed filter - search term - and I only need searching in files and I see now it cant be done at all.
I need that because of other exposed filter which is a date field, so user can search within files and number of file and date of file creation. Last 2 I choose when I upload new pdf.

I already wrote it in Search Files issue but will repeat it here - your module works great with pdftotext, you were not sure about that so I can confirm that, tested - works.

What you would need to do is to use hook_nodeapi and when the node is being rendered for search indexing, add the contents of the file to the rendered node.

Can you help me with that or give some more details ?

I was also thinking to paste all the text content of pdf file to the node cck text field and then it would be searchable... But I would like to hide this field , so the user cannot see that. This is also quite good solution I juse have no idea how to do this automatically. I would like this field to be visible only for search engine from drupal core and for google and other ext search engines.

If you want I can open new issue just about searching inside files because its true I made 2 feature requests here, sorry about that.

Thanks

jhodgdon’s picture

For your "add files to search results", see http://api.drupal.org/api/function/hook_nodeapi/6 with $op = "update index". That is the hook that will allow your module to add information to the node that will be indexed by search. Again, this is not possible within Search by Page, because it is defining a new search and you need to add to the core Content search in order to get into Views. So let's not discuss it any more in the Search by Page issue queue... If you need more help than this hint, please visit http://drupal.org/support to learn about support options.

As far as plans to add the option for node title, it isn't my highest priority right now -- I'm mostly working on helping to get Drupal 7 ready for release. If you want to make this option get added sooner, the best thing would be to develop it yourself and add a patch to this issue. Preferably with some new tests to test the functionality. Then all I would need to do is to verify that the code works and the test is valid, in order to add it to the module. Thanks!

amitaibu’s picture

> So it won't merge with Views searching by keyword

For other to use -- I needed to do it, so as a hack, on node save I get file, extract its content and put it in a CCK field. Here's a stripped down code to illustrate it:

/**
 * Implementation of hook_nodeapi().
 */
function foo_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'presave' && $node->type == 'article') {
	  // We can have multiple files in a node, so iterate over them.
    if (!empty($node->field_pdf_file[0])) {
      foreach ($node->field_pdf_file as $key => $value) {
        $filepath = file_create_path($node->field_pdf_file[$key]['filepath']);
        $result = db_query("SELECT * FROM {files} WHERE filepath = '%s'", $filepath);

        // Ensure case-sensitivity of uploaded file names.
        while ($file = db_fetch_object($result)) {
          if (strcmp($file->filepath, $filepath) == 0) {
            break;
          }
        }

        // If the file is not found in the database, we're not responsible for
        // it.
        if (!isset($file)) {
          return;
        }

        if ($file_content = search_files_attachments_index_file($file)) {
          // Add the file content to the node itself, so it will be indexed.
          $node->field_pdf_file_content[$key]['value'] = $file_content;
        }
      }
    }
  }
}
jwgreene’s picture

I also think (b) would be a very useful feature, and suggest the following implementation:
Currently you display nodeName/attachmentName with the whole thing being a link to the attachment.
Instead have nodeName be a link to the node, and attachmentName be a link to the attachment.
This way users can do either one without having to support more configuration options.

jhodgdon’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Issue summary: View changes