1

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:

<?php
  $block = module_invoke('custom_search', 'block_view', 'custom_search');
  print render($block); 
?>

It displays nothing

Based on below comments i tried doing this:

<?php
$block = module_invoke('custom_search', 'block', 'view', 0);
print $block['content'];
  ?>
6
  • where did you tried this code? and how ?
    – niksmac
    Apr 24, 2013 at 5:07
  • i wrote it in the header of view as Global:PHP
    – why
    Apr 24, 2013 at 5:32
  • See this drupal.stackexchange.com/a/14354/4471
    – niksmac
    Apr 24, 2013 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, 2013 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, 2013 at 9:55

3 Answers 3

4

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

1

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.

0

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.

1
  • nice idea...will look into...
    – why
    Apr 29, 2013 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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