Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

example improved to handle no results for 2nd query

  • Loading branch information...
commit 899e9bd5982d9cddf72a479daa47c143221e34fd 1 parent 70f0860
@microbubble authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 controllers/search_example.php
View
7 controllers/search_example.php
@@ -33,7 +33,12 @@ public function index($msg = NULL) {
$hits = Search::instance()->find($query);
- $results2 = $query->highlightMatches(iconv('UTF-8', 'ASCII//TRANSLIT', $hits[0]->body));
+ if(sizeof($hits) > 0) {
+ $results2 = $query->highlightMatches(iconv('UTF-8', 'ASCII//TRANSLIT', $hits[0]->body));
+ }
+ else {
+ $results2 = '<p style="color:#f00">No results found</p>';
+ }
}
}
catch(Exception $e) {
Please sign in to comment.
Something went wrong with that request. Please try again.