Last updated 12 November 2011. Created on 25 July 2011.
Edited by danielb. Log in to edit this page.

Using PHP

The simplest way to embed a finder with PHP is to enable the 'provide block' option and use code like so:

print theme('block', finder_block('view', 'finder_X')); 

Where X is the finder id integer (which you can figure out from the URL of the admin pages).

If you need more control than this, consider looking into the functions: finder_view(), theme('finder_page'), or theme('finder_block'). You should also check user_access('use finder'); to see if the user has permission to use the finder in these cases, as it is not done automatically like when you embed the block.

If you are embedding a finder into your page.tpl.php file, please be aware that it is much easier to just create a new block region in your template and use the UI to put a finder block there. The reason is that autocomplete finders need a bit of extra work to get them working when embedded in a tpl file, because the JavaScript file will be missing.

Embed finder into a node

If you want to easily embed a finder in a node, try the Block reference module.


More discussion about embedding finders here:
#1214082: Replace core search with a fancy Finder form
#1086360: Autocomplete suggestions not showing up when manually printing with finder_view
#1072020: Embed Finder in other websites
#582276: Embed Finder form in node?

Looking for support? Visit the forums, or join #drupal-support in IRC.


justinireland’s picture

I am trying to embed finder into a mega menu (using muchomenu). Technically the menu is a block so I'm trying to embed finder block into another block. I'm using the code you mention here but the only rendered output I get is this

<div id="block--" class=""> 
  <div class="content"> 
</div><!-- /.block --> 

I could be wrong but it looks like its failing at finder_block(). I am using finder_1 for the first finder in the list. Block is enabled, permissions are ok. I'm really not sure what else I need to do to make this work.

Any help would be appreciated.

alexmoreno’s picture

the finder_block. Did´nt work for me. I did:

$block = module_invoke("finder", "block", "view", "finder_7");
print ($block["content"]);