搜索块在 Drupal 中不起作用
我刚刚在以下位置上传了一个测试网站:www.betterclassofleaders.co.cc/whackk 我正在使用自定义搜索块(通过 search-theme-form.tpl.php 自定义),但它不起作用。如果您输入搜索词并按 Enter 键,它将转到搜索结果页面,但不会实际执行搜索。
搜索结果页面确实可以正常工作。知道可能是什么问题吗?
I just uploaded a test site on the following location : www.betterclassofleaders.co.cc/whackk
I am using a customised search block (customised through search-theme-form.tpl.php) but it does not work. If you type in a search term and hit Enter it will go to the search result page but without actually performing the search.
Searching through the results page does work as normal. Any idea what the problem might be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,您不能直接修改
search-theme-form.tpl.php
中的 HTML,因为这不是正确的方法。所以我添加类以及 onFocus 和 onBlur 属性就是问题所在。正确的方法是修改主题
template.php
文件。基本上我们将使用form_alter()
来修改表单元素。由于使用HTML方式是错误的。看看下面的代码(取自:此处)在
yourthemename_preprocess_search_theme_form
中- “yourthemename”显然会反映您的自定义主题的名称。基本上代码是不言自明的。评论什么的。所以,基本上这就是它的工作方式。
Apparently, you cannot directly modify the HTML in
search-theme-form.tpl.php
since thats not the right way to do it. So my adding the class and onFocus and onBlur attributes was the problem.The correct way to do it is to modify the themes
template.php
file. Basically we will be usingform_alter()
to modify the form elements. Since using the HTML way is wrong. Take a look at the code below (taken from : here )In
yourthemename_preprocess_search_theme_form
- 'yourthemename' will obviously reflect the name of your custom theme. Basically the code is self-explanatory. what with the comments and all.So, basically thats the way it works.