Page 1 of 1

Livesearch - how to use somewhere other than sidebar

Posted: Wed Nov 14, 2007 4:41 pm
by Don Chambers
Bulletproof, and a number of other templates, offer a quicksearch box as a template option. Bulletproof specifically offers this as an option within a likewise optional navigation bar.

I see livesearch has the following hooks:

Code: Select all

            'external_plugin'    => true,
            'frontend_header'    => true,
            'css'                => true,
            'quicksearch_plugin' => true
So what needs to happen to get livesearch to work with the bulletproof navbar version of quicksearch??

EDIT: Can we simply call the quicksearch_plugin hook from our index.tpl?

Re: Livesearch - how to use somewhere other than sidebar

Posted: Wed Nov 14, 2007 6:24 pm
by garvinhicking
Hi!

Check out the generate_content() method of the serendipity_quicksearch_plugin in include/plugin_internal.inc.php. I think it must call the "quicksearch_plugin" plugin API event somewhere.

You'll need to call that hook from within your smarty template file, by using the hookall-parameter of the {serendipity_hookPlugin} call.

It also might need to listen on specific DIV IDs so you'll need to make sure that your template uses similar HTML output for the quicksearch form.

HTH,
Garvin

Posted: Wed Nov 14, 2007 7:01 pm
by Don Chambers
Yes, it does... like this:

Code: Select all

<?php
        serendipity_plugin_api::hook_event('quicksearch_plugin', $serendipity);
    }
The livesearch code has this:

Code: Select all

                case 'quicksearch_plugin':
                    echo '<script type="text/javascript">
                    lsbase = "' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/ls' . ($serendipity['rewrite'] == 'none' ? '_&' : '?') . '";
                    waittext = "' . PLUGIN_EVENT_LIVESEARCH_WAIT . '";
                    notfoundtext = "' . PLUGIN_EVENT_LIVESEARCH_NOTFOUND . '";
                    addLoadEvent(liveSearchInit);
                    </script>';
                    break;

I tried this in my index.tpl file:

Code: Select all

    {serendipity_hookPlugin hook="quicksearch_plugin"}
but received the following error:

serendipity_smarty_hookPlugin: illegal hook 'quicksearch_plugin'

Posted: Wed Nov 14, 2007 8:14 pm
by Don Chambers
I'm not quite there yet, but this seems to be picking up the script:

{serendipity_hookPlugin hook="quicksearch_plugin" hookAll="true"}

Posted: Thu Nov 15, 2007 3:02 pm
by Don Chambers
So Garvin, is this hookAll="true" the correct method? If so, why?

Posted: Thu Nov 15, 2007 3:10 pm
by garvinhicking
Hi!

Yes, it is. Please check the techincal docs on www.s9y.org for the details on hookall.

Regards,
Garvin

Posted: Thu Nov 15, 2007 3:28 pm
by Don Chambers
You beat me to the post Garvin! I finally found something in the docs that I had been looking for to explain this:
* {serendipity_hookPlugin hook="hookname" hookAll="true|false" data=$eventData addData=$addData}
This allows to execute any plugins to call via the Event Plugin API. Using this execution method you can also execute your own created event hooks. The "hook" parameter specifies the used hook name, if "hookAll" is set to true, any plugin hook can executed. If it is not set or set to false, only the hooks "frontend_header", "entries_header", "entries_footer" and "frontend_comment" can be executed via Smarty. Via the "data" and "addData" variables you can pass custom variables to the PHP Plugin API functions.