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@5net.hu | web: http://www.5net.hu
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@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@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
Thanks, but I like to user the other result like the drupal result and I like to mix it. 2009-03-25 16:22 keltezéssel, Khalid Baheyeldin írta:
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@5net.hu <mailto:amont@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@5net.hu <mailto:amont@5net.hu> | web: http://www.5net.hu
-- Khalid M. Baheyeldin 2bits.com <http://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
Á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@5net.hu | web: http://www.5net.hu
You can still do that. You still use the phptemplate_search_page(). Do your own search, and then array_merge() with $results, and then call theme('search_item') on the combined result. 2009/3/25 Ámon Tamás <amont@5net.hu>
Thanks, but I like to user the other result like the drupal result and I like to mix it.
2009-03-25 16:22 keltezéssel, Khalid Baheyeldin írta:
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@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@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
Á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@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
On 25-Mar-09, at 11:48 AM, Ámon Tamás wrote:
Thanks, but I like to user the other result like the drupal result and I like to mix it.
You might also be able to do this with hook_search and hook_update_index. AFAIK there is no restriction on where the content comes from, however it does end up getting indexed in Drupal as well. So it's probably not what you want if you all ready have a search index on the remote site. See http://api.drupal.org/api/group/search/6 and http://api.drupal.org/api/function/hook_search/6 --Andrew
2009-03-25 20:06 keltezéssel, Andrew Berry írta:
On 25-Mar-09, at 11:48 AM, Ámon Tamás wrote:
Thanks, but I like to user the other result like the drupal result and I like to mix it.
You might also be able to do this with hook_search and hook_update_index. AFAIK there is no restriction on where the content comes from, however it does end up getting indexed in Drupal as well. So it's probably not what you want if you all ready have a search index on the remote site.
See http://api.drupal.org/api/group/search/6 and http://api.drupal.org/api/function/hook_search/6
First I like to use the hook_update_index, but it only can to work with node-s, or if I like to insert other content I must use an other type in search_index(). Or is there an other indexer, what can index external sites and easy to use with drupal? It schould be enough... Á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@5net.hu | web: http://www.5net.hu
On 30-Mar-09, at 7:02 AM, Ámon Tamás wrote:
First I like to use the hook_update_index, but it only can to work with node-s, or if I like to insert other content I must use an other type in search_index().
'node' is just a key for the content. You should be able to call search_index on whatever content you want. If you look at the function comments you'll see it's not bound to nodes specifically. search_index($unique_id, 'my_external_content', $some_fetched_text_from_external_site); --Andrew
participants (3)
-
Andrew Berry -
Khalid Baheyeldin -
Ámon Tamás