简体   繁体   中英

Drupal Search in Block View

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.

在此输入图像描述

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.

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/

你试过自定义搜索模块吗?

If anybody is interested, i have edited the header block view and load a custom_search_block inside it.

Thanks anyway

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM