As in title.
Other module should have ability to add their own custom search engines without hacking the module.
In my case I want that serapi_get_search() will return query string of my own site.

CommentFileSizeAuthor
#1 serapi.patch960 byteskenorb

Comments

kenorb’s picture

Status: Active » Needs review
StatusFileSize
new960 bytes

Patch in attachment.

yaph’s picture

Assigned: Unassigned » yaph

Thanks for the patch. One question: should serapi_search_engine_list be named hook_serapi_search_engine_list to be immediately recognizable as a hook?

kenorb’s picture

Status: Needs work » Needs review

No. None of the function can contain 'hook' word.
When you execute module_invoke_all() it will automatically call all the instances of this hook and merge the data. No need to define hook in some special way.
See: http://api.drupal.org/api/function/module_invoke_all/6 ($function = $module .'_'. $hook;)
In my opinion hook_search_engine_list is a better name than get_engine_list, because in hooks you set those engines, not get.
Serapi module it-self contains implementation of this hook, and I've got following function defined in my separated module:

/**
 * Implementation of hook_search_engine_list
 *
 * @return Array
 * Array of search engines
 */
function mymodule_search_engine_list() {
  return array(
    'doc-live' => array(
      'host_pattern' => 'xxx.co.uk',
      'query_param' => 's'
    ),
    'doc' => array(
      'host_pattern' => 'doc',
      'query_param' => 's'
    ),
  );
}

where I've defined my local environment, production and live server.
Functionality is tested and works on my environment.
I need those internal search engines to generate proper breadcrumbs and have access to search keywords from internal search engine.
Some examples of usage serapi module in crumbs module
#926266: How to change the path of the crumbs?
#933230: Add debug option to show which method has been called
#925382: Method of override breadcrumb completely

yaph’s picture

Status: Needs review » Needs work

Thanks for the explanation! I applied your patch locally, but now the tests fail, because of the use of module_invoke_all. I'll see how I can fix this before I commit the changes.

kenorb’s picture

Status: Needs review » Needs work

Thanks.
It will be great.

yaph’s picture

In the latest commit (http://drupal.org/cvs?commit=435576) I renamed serapi_get_engine_list to serapi_search_engine_list and made it a hook. I also added a new function that doesn't call module_invoke_all to be testable.
Thanks again for your great suggestion and patch.

yaph’s picture

Status: Needs work » Needs review

I added a new release with the hook feature http://drupal.org/node/940846

trrroy’s picture

Status: Needs review » Closed (fixed)

This was added to the 6.x-2.0-beta1 release.