块视图中的 Drupal 搜索
我需要创建一个块视图,并将搜索框附加到标题,以便搜索节点以查找一种特定的内容类型。我不知道如何实现这一点,所以我请求你的帮助。就像所附照片一样。
i need to create a block View with a search box attach to the header in order to search nodes for one specific content type. I don't know how to achieve this, so i ask for your help. Something like the attached photo.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我在这里不太确定,但在我看来,您想要:
创建一个视图;
添加一个“过滤器”,将视图限制为仅您想要的内容类型;
添加一个“参数”,然后为标题、正文或文本字段之一公开此参数。
很遗憾:
仅此一点不会搜索整个节点。如果您的大部分内容都在正文中,这可能是一个好方法。但是,例如,如果出于某种原因,您的标题如“廷巴克图的自行车”,其正文不包含“廷巴克图”一词 - 如果您的用户搜索廷巴克图,则该项目将不会出现。也就是说,这可能是一个相当罕见的情况,如果您只是瞄准快乐的用户,而不是严格的完美,这可能就足够了。
也就是说,Kniganapolke 检查自定义搜索的建议非常好。如果您想按照指定的方式执行此操作并使用视图(以及它们提供的其他可能性)的功能,而不是更专用的模块,那么这里的建议更适用。如果您没有其他规范要求您使用视图,我猜自定义搜索可能是更好的解决方案。
I'm not exactly sure here, but it sounds to me like you want to:
Create a view;
add a "filter" which limits the view to only your desired content type;
add an "argument," and then expose this argument, for either title, body, or one of your text fields.
Unfortunately:
This alone will not search the whole node. If most of your content is in body, this would probably be a good way to do it. But, for example, if for some reason you have a title like "Bicycles in Timbuktu" with a body that does not contain the word "Timbuktu" - were your users to search for Timbuktu, this item would not appear. That said, it's probably a rather rare case, and if you are simply aiming for happy users, and not rigorous perfection, this will likely be enough.
That said, Kniganapolke's suggestion of checking out Custom Search is excellent. The advice here is more applicable if you want to do this as you've designated and using the power you have with Views (and the other possibilities they offer), rather than a more dedicated-type module. If you don't have other specifications which require you to use Views, I'd guess that Custom Search will likely be the better solution.
您是否尝试过自定义搜索模块?
Have you tried Custom Search module?
如果有人感兴趣,我已经编辑了标题块视图并在其中加载了一个 custom_search_block 。
无论如何,谢谢
If anybody is interested, i have edited the header block view and load a custom_search_block inside it.
Thanks anyway
创建包含所需内容的视图,然后按内容过滤它。暴露过滤器。
http://beeznest.wordpress.com/2011/11/01/create-a-view-to-search-on-content-title-in-7-steps-in-drupal-7/
create a view with the content you want and then filter it by content. Expose the filter.
http://beeznest.wordpress.com/2011/11/01/create-a-view-to-search-on-content-title-in-7-steps-in-drupal-7/