changeset 1487:ad473f8dc533

output no results found message as a msg to the previous page
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Fri, 25 Aug 2006 12:13:24 +0200
parents 5d30213ee39b
children 2178a0153213
files MoinMoin/action/fullsearch.py
diffstat 1 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/fullsearch.py	Fri Aug 25 11:49:45 2006 +0200
+++ b/MoinMoin/action/fullsearch.py	Fri Aug 25 12:13:24 2006 +0200
@@ -146,6 +146,14 @@
             url = page.url(request, querystr={'highlight': query.highlight_re()}, escape=0, relative=False)
             request.http_redirect(url)
             return
+    # no hits?
+    elif not results.hits:
+        err = _('Your search query {{{"%s"}}} didn\'t return any results. '
+                'Please change some terms and refer to HelpOnSearching for '
+                'more information.') % needle
+        Page(request, pagename).send_page(request, msg=err)
+        return
+
 
     request.emit_http_headers()
 
@@ -158,27 +166,19 @@
     # Start content (important for RTL support)
     request.write(request.formatter.startContent("content"))
 
-    # Did we get any hits?
-    if results.hits:
-        # First search stats
-        request.write(results.stats(request, request.formatter, hitsFrom))
+    # First search stats
+    request.write(results.stats(request, request.formatter, hitsFrom))
 
-        # Then search results
-        info = not titlesearch
-        if context:
-            output = results.pageListWithContext(request, request.formatter,
-                    info=info, context=context, hitsFrom=hitsFrom)
-        else:
-            output = results.pageList(request, request.formatter, info=info,
-                    hitsFrom=hitsFrom)
-        request.write(output)
+    # Then search results
+    info = not titlesearch
+    if context:
+        output = results.pageListWithContext(request, request.formatter,
+                info=info, context=context, hitsFrom=hitsFrom)
     else:
-        f = request.formatter
-        request.write(''.join([
-            f.heading(1, 3),
-            f.text(_('Your search query didn\'t return any results.')),
-            f.heading(0, 3),
-        ]))
+        output = results.pageList(request, request.formatter, info=info,
+                hitsFrom=hitsFrom)
+
+    request.write(output)
 
     request.write(request.formatter.endContent())
     request.theme.send_footer(pagename)