[development] Search
Khalid Baheyeldin
kb at 2bits.com
Wed Mar 25 15:22:01 UTC 2009
This is what we do on a Drupal 5 site. Should work more or less the same on
D6 as well.
In template.php, we include an inc file that handles the XML from the
external site, and then we add "sponsored results". Like so:
function phptemplate_search_page($results, $type) {
$enable_external = FALSE;
$external = path_to_theme() . '/something_search.inc';
if (file_exists($external)) {
include_once($external);
if (function_exists('external_search')) {
$enable_external = TRUE;
// This is the search term. Remove + in case it is a multiword search
//$key = trim(preg_replace('/\+/i', ' ', arg(2)));
$key = arg(2);
// run the function to get results
$external_results = external_search($key);
list($jr_top, $jr_bottom, $jr_sidebar) = $external_results;
}
}
$output = '<dl class="search-results">';
if ($enable_external) $output .= '<div class="sponsored">' . $jr_top .
'</div>';
foreach ($results as $entry) {
$output .= theme('search_item', $entry, $type);
}
if ($enable_external) $output .= '<div class="sponsored">' . $jr_bottom .
'</div>';
$output .= '</dl>';
$output .= theme('pager', NULL, 10, 0);
return $output;
}
2009/3/25 Ámon Tamás <amont at 5net.hu>
> Hello,
>
> I like to add some search result from a different site to drupal. I like to
> show the search results mixed in the other and drupal site. I try to use
> mnogosearch to index the other site, but I can not insert the results to the
> drupal results. How can I make it?
>
>
>
> Ámon Tamás
>
> Sitefejlesztő és programozó
> --
> 5NET Informatikai Kft.
> 1062 Budapest, Aradi utca 38. A 3/11
> telefon: (1) 461-0205 | fax: (1) 461-0206
> e-mail: amont at 5net.hu | web: http://www.5net.hu
>
>
--
Khalid M. Baheyeldin
2bits.com, Inc.
http://2bits.com
Drupal optimization, development, customization and consulting.
Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra
Simplicity is the ultimate sophistication. -- Leonardo da Vinci
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/development/attachments/20090325/a8119202/attachment.htm>
More information about the development
mailing list