Drupal:hook_search 仅适用于内容类型
我想在 Drupal 6 中构建一个自定义搜索模块,用于通过 CCK 进行搜索。我需要用户在其节点 (node.uid=x
) 和某种类型 (type='xyz'
) 之间进行搜索。我想我必须实现 hook_search
但我不知道在哪里放置我的过滤器。谁能帮助我吗?
I would like to build a custom search module in Drupal 6 for searching through CCK. I need the user to search between his nodes (node.uid=x
) and of a certain type (type='xyz'
). I think I have to implement hook_search
but I don't know where to put my filters. Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您已经接受了答案(这可能是您的最佳选择),但是还有一些其他方法可以实现此目的。
IIRC,自定义搜索模块将满足您的需求。
您可以将库存
hook_search
函数复制到自定义模块并修改查询。您可以执行以下操作:这会替换从实际查询字符串中提取类型的位。
您必须添加该位才能重构为特定的
n.uid
。我最近一直在使用这种方法,而不是自定义搜索,因为从用户的角度来看它更简单。华泰
You already accepted an answer (which is probably the best option for you), but there are a few other ways to accomplish this.
IIRC, the Custom Search module will work for what you want.
You can copy the stock
hook_search
function to a custom module and modify the query. You can do something like this:This replaces the bit that extracts the type from the actual query string.
You would have to add in the bit to restruct to a particular
n.uid
. I have been using this method lately, rather that Custom Search, because it simpler from the user's perspective.HTH
您可以尝试使用公开的过滤器创建视图,这绝对是实现您的想法的最简单方法。
You might try creating a Views with an exposed filter, it's the absolute easiest way to implementing your idea.
您也可以尝试使用CCK Facets。但是视图——当然很简单。
Also you can try use CCK Facets. But Views - of course simple.