Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
Drupal themed 404 error pages may have a search field (for example http://drupal.org/foobar or something else on drupal.org that does not exist), however, that search field itself is not functional (you enter something, submit it, and are back on the page not found page). It would be nice if it could be made to work, because usually, when you get a 'page not found' error, the first thing you want to do is probably use the search function to find the correct page.
Regards
frostschutz
Comment | File | Size | Author |
---|---|---|---|
#5 | 404_search_patch0.txt | 465 bytes | pwolanin |
Comments
Comment #1
craines CreditAttribution: craines commentedWe found this same problem when arriving at an error 403. I'm not sure as to the exact cause, but it appears to stem from the fact that the action parameter of the search block form defaults to the same url as the current page.
When you submit, the search module seems to intercept it and redirect you to the search results -- but this doesn't happen on a 404, 403, or on pages such as project/issues (my guess is that the project module intercepts it first -- you can try it out by using the search block at drupal.org/project/issues).
We fixed it by setting the $form['#action'] to 'search/node' (search.module drupal v4.7.2, lines 1041 & 1042 below). This seems to work fine on our site but not sure of the full ramifications of this change...
Comment #2
RobRoy CreditAttribution: RobRoy commentedI think this is at least a 'normal' issue. Could we somehow check if we are on a 404/403 page and then change the action to search/node? Or, are there any issues with always having the action set to this?
Comment #3
rickvug CreditAttribution: rickvug commentedSee the Search 404 module: http://drupal.org/node/26010 . This might be what you are looking for.
Comment #4
RobRoy CreditAttribution: RobRoy commentedThat looks like a nice module, but not the issue. When going to http://drupal.org/foobar and then trying a search from the search box, say for "Drupal". You don't get a list of search results as the action of that form is going to a non-existing page.
Comment #5
pwolanin CreditAttribution: pwolanin commentedI'm seeing the same behavior on the 403 or 404 page- very non-intuitive.
The fix in #1 seems to work for me, and I don't see why it should cause any problems, given the submit function:
Attached as a patch against 4-7-CVS version of search.module.
Comment #6
beginner CreditAttribution: beginner commentedIt's simple enough and it works (tested on cvs/head).
(I'm just a little confused at the way you create 4.7-cvs patches :) I had to manually enter the name of the file to patch -- maybe it's intended this way.)
Comment #7
pwolanin CreditAttribution: pwolanin commentedSome of these patches are made just against a copy of the original file using "diff" on the command line (Mac OSX). They work fine for me with "patch -p0 < patchfile" on the command line. Most of my more recent patches have been made with "cvs diff" (now that I've sort of got the hang of cvs), and that produces a slightly different header- perhaps that's the difference.
Comment #8
drummCommitted to HEAD with a modified comment.
Comment #9
pwolanin CreditAttribution: pwolanin commentedcommited to 4.7 branch?
Comment #10
drummNo need to ask... killes will get to it.
Comment #11
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedbackported
Comment #12
(not verified) CreditAttribution: commentedComment #13
Scott CreditAttribution: Scott commentedThe current download of 4.7.3 does not include the patch for this bug in search.module
Comment #14
pwolanin CreditAttribution: pwolanin commentedyou are correct- the reason is that released versions are fixed. You can get the latest patched version of 4.7 at: http://drupal.org/drupal-4.7-cvs, otherwise this patch will be included when there is a 4.7.4 release.
Comment #15
(not verified) CreditAttribution: commented