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.
When a user browsing my website ends up on the 404 error page and tries to use the search, it loads the 404 error page again.
Upon inspecting the search block, the form action uses the current page. So in this case the action is the URL that landed the user on the 404 error page.
Example:
mydomain.com/test results in 404 error - then the form action for the search block will be set to /test
Since this URL is not valid - when the user searches from the 404 page, it returns to itself instead of /search/node/$keywords
Comment | File | Size | Author |
---|---|---|---|
#13 | custom_search_404-2140129-13.patch | 1.29 KB | kmonty |
#12 | custom_search_url.patch | 2.02 KB | tamer.kamel |
#2 | search-block-action-2.patch | 678 bytes | jdanthinne |
searchBlock_FormAction.PNG | 5.03 KB | certifiedGeek |
Comments
Comment #1
certifiedGeek CreditAttribution: certifiedGeek commentedI tried the following code in my template.php, but I think the action must be dynamically set somewhere else.
Comment #2
jdanthinne CreditAttribution: jdanthinne commentedCan you try the attached patch?
Comment #3
tarheeldev CreditAttribution: tarheeldev commentedI tested the patch and it appears to work. Thank you.
Comment #4
jdanthinne CreditAttribution: jdanthinne commentedGreat news. Thanks for the review.
Comment #7
jdanthinne CreditAttribution: jdanthinne commentedThe patch broke the custom blocks for many user… that was not the correct solution then.
Comment #8
sylus CreditAttribution: sylus commentedHas there been any progress on this issue as has been tripping me up as well. Was the only reason the previous patch removed because other search paths were being used?
Comment #9
jdanthinne CreditAttribution: jdanthinne commentedThe reason to remove the parch was this issue: #2233325: upgrading to 1.14 breaks custom search block.
Being busy updating the module for D8, no progress has been made… but help is welcome.
Comment #10
vfranklyn CreditAttribution: vfranklyn commentedHi there. I've run into this problem on my D7 site. Has there been any further development on this issue, by any chance? Is there something you could suggest I do on my end that might fix it? I know you are busy and it really is a terrific module, so thank you.
I'm completely unskilled in any sort of code contribution, so I'm sorry I can't help.
Comment #11
SDJH CreditAttribution: SDJH commentedHi All, just run into this issue for my D7 website. Exactly the same problem as described above, has anyone made any progress on this? Not entirely confident using the above patch as it seems a bit risky.
Comment #12
tamer.kamel CreditAttribution: tamer.kamel commentedTo change the url of search result page from search/node/[key] to another like mysearch/[key] through custom search module there is function missing here to define the new url which is mysearch/[key] in the meny. you can create any module with hook hook_menu_alter or just add this path to custom search module.
I tested this well and I hope fixed the problem with you like me. welcome for any reply.
Comment #13
kmontyThe patch in #12 did not work on my site. However, #2 did.
I realize the #2 patch broke sites--presumably because they did not have the path as defined. Here is a hybrid patch that combines the fix in comment #2 from @jdanthinne with some of the logic in #12 from @tamertama.
My attempt with this patch is to allow site owners to have different search paths other than
search/node
. I recognize this might not be perfect, but I hope it's a valuable starting point to resolve this issue.Comment #14
kmonty