In the following lines I'll try to explain the steps I took in order to substitute the core search with Finder.
I'll detail my specific scenario (Theme, Finder options, etc.) but bare in mind that it can be adapted to fit anyone needs. I hope this would of use to anyone looking for the same feature.
Needles to say, this is the way I found. There surely are better ways to achieve this.

So, let's start with what I'm using:

  • Drupal 6.20
    • Search module Enabled.
    • Search box Enabled. (admin/build/themes/settings/[your_theme])
  • Finder 6.x-1.10
    • Finder Autocomplete
    • Finder Node
  • Theme: Framework 6.x-3.0



01. Create a Finder form:
Site building > Finder > Add finder
Here you can choose the options that best suit your needs.
My objective was to make the search as much user friendly and cool as possible. Here is what I chose:

  • Path: Although it was not what I intended, I guess you can completely override the core search result page by setting this to search/node.
  • Provide block Must be enabled.
  • Button text: Search Not really needed.
  • Show results on results page even before the form has been completed Disabled. This won't work if you are using just a Block.
  • Validate empty submission Enabled. This will avoid whole database scanning when nothing is entered in the search field.
  • Use submit button Enabled. We will need this.
  • Use AHAH on submit button As of bug #1214024: Use of AHAH and a block occasionally breaks theme all AHAH options should be disabled.
  • Pager: 0 We will disable paging due to bug #1214028: Pager and Redirect to the only result issue.
  • Redirect to result: Redirect to the only result, or show results page if there are multiple results. If you choose any other option here, you won't need to disable paging.
  • Hide URL arguments on results page Enabled.



02. Add an Element:
From the bottom of your newly created Finder, add an element.
I used an Autocomplete textfield. You have some other options at your disposal. Just enable them from the Modules page.
Once again, you should choose whatever fits you best. In order to provide the less restrictive experience possible I choose:

  • Autocomplete matching: Contains.
  • Submit upon selection Enabled. This is cool. =)
  • Result matching: Contains.



03. Configuring the block:
Site building > Finder > Blocks
In the block list, locate the block that was automatically created by your Finder. It should be named something like: Finder: [Finder Title]. Once located, click con Configure.
You may want to set the Block title: to <none> here in order to hide its title.
While being here, take note of the URL; we will need it soon. It should like like this:
admin/build/block/configure/finder/finder_1
Go back to the previous screen (Save if you made modifications) and set this block to the Footer region, or wherever it won't bother much. You will find out why in a few lines.



04. Duplicate the block:
From the block list, Add a new block.
Once again, you can set the Block title: to <none> here in order to hide its title.
In Block body: we will use the following piece of code:
$block = (object) module_invoke('[module]', 'block', 'view', '[id]'); print theme('block',$block); [module] and [id] are taken from the previously noted URL. Like this:
admin/build/block/configure/[module]/[id]
While you are here, configure you block to Show on only the listed pages..
For instance, using search/books will show the block on http://yoursite.net/search/books.
You can match this with the Path you defined in your Finder to make the block appear only on the Finder results page.



05. Replace the core search box:
Time to hack into the theme files!
Edit the Page template file (page.tpl.php) from your theme directory:
Example: sites/all/themes/[your_theme]/page.tpl.php
Replace the code where the search box is printed with what we used to create the block.
In my Framework theme, I changed this:
<?php if ($search_box): ?><?php print $search_box ?><?php endif; ?>
into this
<?php if ($search_box): ?><?php $block = (object) module_invoke('finder', 'block', 'view', 'finder_1'); print theme('block',$block); ?><?php endif; ?>
Save the changes and clear you site cache:
Site configuration > Performance > Clear cached data



06. Theme to clean the mess.
Through CSS theming we must make the new search box look pretty and hide the unnecessary block at the Footer. You will need some CSS knowledge for this, but it is somewhat easy and information is available on the web. Also, Firefox and add-on Firebug will be very useful here to know the classes and ids applied to every page element.
Basically, you will need to edit the CSS file for your theme and add the required modifications.
This file will probably be located at: sites/all/themes/[your_theme]/style.css

I won't extend on CSS here, but these are the modifications I made in my Framework theme:

/* I applied the same style that was applied to the core search box */
#header #block-- {
  float: right;               
  margin: 1.3em 0 0;
}

/* Here, I'm hiding the title of the new search box, */
#header #block-- h2,
/* also hiding the title of the right search box (block) */
#sidebar-right #block-- h2,
/* hiding labels from the main search box */
#header #block-- label,
/* hiding the complete footer block */
#footer #block-finder-finder_1 {
  display: none;
}

/* Here I position the main search box exactly how and where I like it */
#header #block-- .form-item {
  float: left;
  margin-bottom: 0;
  margin-right: 5px;
  margin-top: 0;
  position: relative;
  top: 1px;
}

#sidebar-right #block-- .form-item {
  margin-top: 0;
}



That's it! Despite this guide seems quite long, it's fairly simple.
The most tedious part may be to play around with CSS if you are not familiar with it.
Hope someone finds this piece useful.

Please, if you are and experienced coder/themer, don't laugh about my implementation.
I know this is as noobish as it can be. =)

If you have any comments or recommendations, you are welcome!

Hope this is an acceptable place for this; as I have seen guides/tutorials on the issue queue before.
Thanks to danielb for this nice module.
Have a nice day! and excuse any grammar mistakes; English is not my first language.



Almost forgot!
Why do you need an extra block?
When you set the real Finder block to show only on some pages, the piece of code needed to make the Autocomplete feature work will only be loaded on that pages. As we put the Finder form in place of the core search box, we will need this feature on every page.
That's why we secretly load the original Finder block on the bottom of every page, and we need a duplicate to load at the Finder results page.

Comments

danielb’s picture

If you like you could copy/paste this into a new "child page" from http://drupal.org/node/477074

danielb’s picture

If you don't want to invoke the finder from the block, you should note that if your finder uses autocompletes, the relevant javascript will need to be manually included using drupal_add_js(). The reason for this is that by the time the template gets executes the $scripts variable has already been set, so finder autocomplete scheduling the js file for addition won't work. The exact script to add will depend on the configuration of your finder, specifically whether you've set the 'submit upon selection' option.

If you have not enabled the 'submit upon selection' option, the code to put in template.php is:

drupal_add_js('misc/autocomplete.js');

Whereas if you have enabled the option it would be:

drupal_add_js(drupal_get_path('module', 'finder_autocomplete') .'/finder_autocomplete.js');

Here is the issue where this first came up: #1086360: Autocomplete suggestions not showing up when manually printing with finder_view

danielb’s picture

Although really, isn't it easier to just disable the search tool in the theme configuration and put a block in the same spot with a finder?

realOFF’s picture

Hi danielb. Thanks for sticking in.

My theme doesn't have a Region on/near the core Search Box. That's why I followed this approach.
In spite of not having a suitable Region defined in that place, is there a better way to do it?

On the issue you referenced, the OP seems to be using print finder_view(finder_load(3), 'block') to show his Finder.
Will that function show my Finder wherever I embed it? Is this documented somewhere?

Thanks.

danielb’s picture

How hard is it to define a new block region where your searchbox used to be? I think it's easier than messing around with embed code.

On the issue you referenced, the OP seems to be using print finder_view(finder_load(3), 'block') to show his Finder.
Will that function show my Finder wherever I embed it? Is this documented somewhere?

No it isn't documented specifically, other than what's in the doxygen comments on the functions.
The best way to embed the block is to embed it the same way you would with any drupal block. This will ensure permissions and call appropriate hooks before displaying.

Invoking the finder block the 'drupal' way will in turn call theme('finder_block', $finder); which in turn calls finder_view($finder, 'block'). I guess finder_view($finder, 'block'); is analogous to node_view($node, 'teaser'); and it can be very useful in some cases, but you might not get all the bells and whistles of the block if, and you will bypass permissions (of course you can check permissions yourself).

danielb’s picture

Also note that in your block embed code you have [module] like module would ever change? [module] will always be 'finder'.

Notice that:

$block = module_invoke('finder', 'block', 'view', 'finder_X');

is really just a long way of writing:

$block = finder_block('view', 'finder_X');

Where X is the finder id integer.

So you can get your template output like this:

<?php if ($search_box): ?><?php print theme('block', finder_block('view', 'finder_X')); ?><?php endif; ?>

But yeah, I prefer to just create a region there and stick the block in through the block admin page, so you can avoid the extra work to get autocompletes working.

Technically if you're awesome, you won't even care where exactly the region is because you can use CSS to nudge it over to where you need.

danielb’s picture

Status: Active » Fixed

I've added a documentation page summarising this, and linking to a bunch of these embed issues:
http://drupal.org/node/477074

realOFF’s picture

danielb, thanks for your suggestions and taking the time to document this.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Rishi Kulshreshtha’s picture

@realOFF and @danielb thanks for this tutorial, I'm looking out for the same things for Drupal 7.x any suggestions how?