0
如果apachesolr在單獨的模塊中爲搜索查詢返回空結果,我正在尋找執行一些代碼。我期待離開apachesolr模塊和acquia模塊不變。如何確定apachesolr是否返回空結果
如果apachesolr在單獨的模塊中爲搜索查詢返回空結果,我正在尋找執行一些代碼。我期待離開apachesolr模塊和acquia模塊不變。如何確定apachesolr是否返回空結果
我一直在尋找同樣的東西,發現此評論很有幫助:
http://drupal.org/node/877346#comment-3310554
基本上你只覆蓋theme_box功能的template.php在你的主題,並檢查標題和內容匹配默認「無結果」模板。
我最終什麼了:
function mytheme_box($title, $content, $region = 'main') {
if ($title == t('Your search yielded no results') &&
$content == variable_get('apachesolr_search_noresults', apachesolr_search_noresults())) {
if ($_GET['fuzzyhelp']) {
// No results with fuzzy, go to landing page for no results.
drupal_goto('search_no_results');
}
// Rewrite search keys with fuzzy characters.
$keys = array_map('trim', explode(' ', search_get_keys()));
drupal_goto('search/apachesolr_search/'. implode('~ ', $keys). '~', 'fuzzyhelp=1');
}
else if ($_GET['fuzzyhelp']) {
// Tell user search was rewritten with fuzzy notations.
drupal_set_message(t('Your exact search did not match any products and was broadened to include all possible matches.'));
}
return $content;
}