[development] Display Search Results as they are Located

Ron Parker sysop at scbbs.com
Mon Nov 10 20:09:14 UTC 2008




I have a custom search. Right now, the search results page is displayed after the search is completed. 

Is there a way to display the search results as they are located? 




For example, in the hook_search api http://api.drupal.org/api/function/hook_search/5 , this is how the results are located in a generic custom search: 

<?php 
case 'search' : 
$find = do_search ( $keys , 'node' , 'INNER JOIN {node} n ON n.nid = i.sid ' . node_access_join_sql () . ' INNER JOIN {users} u ON n.uid = u.uid' , 'n.status = 1 AND ' . node_access_where_sql ()); 
$results = array(); 
foreach ( $find as $item ) { 
$node = node_load (array( 'nid' => $item )); 
$extra = node_invoke_nodeapi ( $node , 'search result' ); 
$results [] = array( 'link' => url ( 'node/' . $item ), 
'type' => node_invoke ( $node , 'node_name' ), 
'title' => $node -> title , 
'user' => theme ( 'username' , $node ), 
'date' => $node -> changed , 
'extra' => $extra , 
'snippet' => search_excerpt ( $keys , check_output ( $node -> body , $node -> format ))); 
} 
return $results ; 
?> 
What I am asking: Is there a way to print each $result[] item as it is located rather than returning the $results array to print the page after the search is completed? 




My problem is that my custom search uses a 3rd party search, then I have to parse the those results using a query to a Drupal table. Then, I populate the $results array. This is taking a very long time, but I don't see a lot of ways round it. What would give the impression of it not taking so long would be if the search results started popping up immediately. 




Thanks for any suggestions. 





-ron 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20081110/16d9d995/attachment.htm 


More information about the development mailing list