"Perhaps you were looking for" box now only shows if strlen($q) >= 4
authorDan
Sat, 06 Oct 2007 20:44:24 -0400
changeset 168 01bf6b1b8222
parent 167 bee40e39321b
child 169 250aeb408ed7
"Perhaps you were looking for" box now only shows if strlen($q) >= 4
plugins/SpecialSearch.php
--- a/plugins/SpecialSearch.php	Sat Oct 06 20:39:18 2007 -0400
+++ b/plugins/SpecialSearch.php	Sat Oct 06 20:44:24 2007 -0400
@@ -100,18 +100,21 @@
   if(!empty($q))
   {
     // See if any pages directly match the title
-          
-    for ( $i = 0; $i < count ( $paths->pages ) / 2; $i++ )
+    
+    if ( strlen($q) >= 4 )
     {
-      $pg =& $paths->pages[$i];
-      $q_lc = strtolower( str_replace(' ', '_', $q) );
-      $q_tl = strtolower( str_replace('_', ' ', $q) );
-      $p_lc = strtolower($pg['urlname']);
-      $p_tl = strtolower($pg['name']);
-      if ( strstr($p_tl, $q_tl) || strstr($p_lc, $q_lc) && $pg['visible'] == 1 )
+      for ( $i = 0; $i < count ( $paths->pages ) / 2; $i++ )
       {
-        echo '<div class="usermessage">Perhaps you were looking for <b><a href="' . makeUrl($pg['urlname'], false, true) . '">' . htmlspecialchars($pg['name']) . '</a></b>?</div>';
-        break;
+        $pg =& $paths->pages[$i];
+        $q_lc = strtolower( str_replace(' ', '_', $q) );
+        $q_tl = strtolower( str_replace('_', ' ', $q) );
+        $p_lc = strtolower($pg['urlname']);
+        $p_tl = strtolower($pg['name']);
+        if ( strstr($p_tl, $q_tl) || strstr($p_lc, $q_lc) && $pg['visible'] == 1 )
+        {
+          echo '<div class="usermessage">Perhaps you were looking for <b><a href="' . makeUrl($pg['urlname'], false, true) . '">' . htmlspecialchars($pg['name']) . '</a></b>?</div>';
+          break;
+        }
       }
     }