Drupal 5 搜索不适用于 404 页面

发布于 2024-08-25 16:40:00 字数 411 浏览 6 评论 0原文

我有一个 在我的 page.tpl.php 页面中。在存在的页面上,搜索可以工作,但在 404 页面上,则不能。

我在 drupal.org 上看到了 D6.15 的一些错误/补丁线程,但它们似乎都没有按照线程工作,而且它们与 D5.x 并不真正相关。

我有一个理论,因为 创建一个对其自身有操作的表单(一个不存在的页面),它会得到 404。

有人遇到过这个吗?如果是这样,你是如何解决的?

我的一个理论是以某种方式利用表单并始终使操作=“/”(首页)始终存在。

如果这是个好主意,那么如何利用 FormAPI 并覆盖操作呢?它是一个预处理函数吗?

I have a <?php print $search_box; ?> in my page.tpl.php page. On pages that exist, the search works, but on 404 pages, it does not.

I saw some bugs/patches threads over at drupal.org for D6.15, but none of them seem to work according to the thread and they weren't really relevant to D5.x

I have a theory that the because the <?php print $search_box; ?> creates a form with an action to itself(a non-existant page), it'll get the 404.

Has anyone run up against this? If so, how did you fix it?

One theory I has was to somehow tap into the form and always make the action="/" (front page) which would always exist.

If this is a good idea, how does one go about tapping into the FormAPI and overwriting the action? Is it a preprocess function?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花伊自在美 2024-09-01 16:40:00
  1. 表单更改中,您可以使用drupal_get_headers() 检查正在显示的页面是否是 404。
  2. 如果是404,您可以在表单中更改搜索表单中的 $form['#action'] 属性,以固定首页或您希望将用户重定向到的任何其他页面。

我还没有测试过这个,但它应该有效。

  1. In a form alter you can use drupal_get_headers() to check if the page being displayed is a 404.
  2. If it is a 404, you can in your form alter set the $form['#action'] attribute in your search form to fx the front page or any other page that you would like to redirect the user to.

I haven't tested this, but it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文