modxcms/revolution — pull request #12041 by rtripault (2014-10-10 12:29:23+00:00)
Title: First step on allowing developers to "hook" into the search bar

### What does it do ?

Introduce a new system event `OnSearch`.

### Why is it needed ?

This would allow developers to plugins to display their results (ie. from external DB/component).

### Usage/notes

The event sends 3 parameters :

* (string) `query` : the raw query
* (int) `limit` : the maximum number of results to return
* (string) `actionToken` : the string "token" used to indicate user is looking for an action (currently not supported in "core search")

The search processor expect a multidimensional array as output (`$modx->event->_output`).

Single record array :

* (string|int) `_action` : the action URI (minus the `a=`)
* (string) `label` : the label to display for the result section (ie. "Resources", "Snippets", "My custom objects")
* (string) `icon` : the icon CSS class (currently suppose FontAwesome), ie. `heart` to produce a `icon icon-heart` result
* (string) `name` : the record name/title/label
* (string) `description` : the record description
* (string) `type` : a string to define the "section type" (to group results), (ie. "resources", "my-objects"...)

Example

```
array(
'name' => $item->get('field_used_as_name'),
'_action' => 'edit&namespace=mycomponent&id=' . $item->get('id'),
'description' => $item->get('field_used_as_description'),
'type' => 'my-custom-object',
'label' => 'My Custom Objects',
'icon' => 'cube',
)
```

### To do before merge

- [ ] Discuss, clean, optimize the search processor
- [ ] Do not assume icons will use FontAwesome with the `icon icon-*` syntax
- [ ] Create the system event during upgrade