用于过滤结果的搜索挂钩?
我一直在浏览文档和源代码,寻找一些没有运气的东西。
是否有一个 Drupal 6 钩子在 hook_search() 之后、$results 传递到模板系统之前被调用?
我需要对返回的结果进行相当定制的修剪和重新排序。我可以重新实现 hook_search(),但这似乎有点矫枉过正。
谢谢。
I have been going through the docs and source code looking for something without luck.
Is there a Drupal 6 hook that gets called after hook_search(), but before the $results gets handed off to the template system?
I need to do a fairly custom pruning and reordering of results that get returned. I could just reimplement hook_search(), but this seems like overkill.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有;
search_view()
(显示结果)调用 < a href="http://api.drupal.org/api/function/search_data/6" rel="nofollow noreferrer">search_data()
,它调用hook_search ()
然后立即对结果进行主题化。重新实现 hook_search() 可能是最直接的途径。话虽如此,您可以改为实现
hook_menu_alter()
并让搜索页面调用您的自定义函数,而不是调用search_view()
(并随后调用search_data()
)。像这样的东西:There isn't;
search_view()
(which displays the results) callssearch_data()
, which invokeshook_search()
then immediately themes the results. Re-implementinghook_search()
is probably the most straightforward route.With that said, you could instead implement
hook_menu_alter()
and have the search page call your custom function instead of callingsearch_view()
(and subsequently callingsearch_data()
). Something like:您可以使用
hook_search_page()
对搜索结果重新排序或格式化。You can use
hook_search_page()
to reorder or format the search result.Hook search_execute 允许您按照您需要的方式修改查询。您甚至可以使用自定义 sql 触发新查询,例如:
Hook search_execute allows you to modify the query in the way you needed. You can even fire new queries with custom sql, for example: