Livesearch - how to use somewhere other than sidebar

Creating and modifying plugins.
Post Reply
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Livesearch - how to use somewhere other than sidebar

Post 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?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Livesearch - how to use somewhere other than sidebar

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post 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'
=Don=
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post 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"}
=Don=
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

So Garvin, is this hookAll="true" the correct method? If so, why?
Last edited by Don Chambers on Thu Nov 15, 2007 3:22 pm, edited 1 time in total.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

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

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post 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.
=Don=
Post Reply