I am using the search box provided from the Custom Search module. It works great. I want to know if there is any way by which i can include the search box in a view which i have created. Regards

PS: I tried this but no effect:

  $block = module_invoke('custom_search', 'block_view', 'custom_search');
  print render($block); 

It displays nothing

Based on below comments i tried doing this:

$block = module_invoke('custom_search', 'block', 'view', 0);
print $block['content'];
  • where did you tried this code? and how ? – niksmac Apr 24 '13 at 5:07
  • i wrote it in the header of view as Global:PHP – why Apr 24 '13 at 5:32
  • See this drupal.stackexchange.com/a/14354/4471 – niksmac Apr 24 '13 at 5:34
  • Also is it true as the below answer says that "You can not include search box generated by custom search module into views"....? – why Apr 27 '13 at 8:06
  • Do you mean to just display the block on a view page? Or do you want to search on the view results? – Volker Apr 27 '13 at 9:55

If you are trying to filter views result, then adding Custom Search block will not work. To get this work you need to add Global: Combine fields filter under Add filter criteria, then select fields on which you want to filter the result from Choose fields to combine for filtering. Expose this field to display a search text field. Please check screenshot below:

enter image description here


You can not include search box generated by custom search module into views, but you can add exposed filter into views to implement search functionality in the views.

To implement search functionality in the views

  • Add "field" in the filter and choose "Contains" from the operator list
  • Exposed field in the filer

It will display a search box for that field in the views and work nicely for searching.


You may just try to expose the "Custom Search 1"-block found in the block-list under admin/structure/block. In the configuration settings for the block admin/structure/block/manage/custom_search_blocks/1/configure you can set the visibility settings for the block to your views-page by inserting your path to the view page.

  • nice idea...will look into... – why Apr 29 '13 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.