BMO Search Provider

image2015-10-20 13_18_19.png

BMO provides a search engine to allow full text searching of data provided by modules. This is provided as an Ajax call by the Search input box in the header.

Modules do NOT need to filter their results, but are provided with the query string as the first parameter, in case the module wants to return a different set of results. A basic string match is applied against the returned "text" value using  if (strpos($r['text'], $qs) === false) to strip out the non-matching results. You may add a key of "force" set to true to skip this check and always display the search result to the client.

namespace FreePBX\Modules; class Ponies extends \FreePBX_Helpers implements \BMO {     public function search($query, &$results) {         $results[] = array("text" => "Drainbow Rash", "type" => "get", "dest" => "?display=ponies&edit=1");         $results[] = array("text" => "Google It!", "type" => "get", "dest" => "https://google.com", "force" => true);     } }

Usage

$this->search($query, &$results);

Format of $results

This is an associative array, with one entry per line to be returned

  • text
    String to be displayed. Automatic highlighting of matched text that its typed is performed by the browser.

  • type
    'get' or 'text'. If get, the dest key must be provided. If 'text', the entry is not selectable. You may add other formatting in html here, such as "<h3>Heading</h3>". Text entries will always be displayed, as if 'force' was set.

  • dest
    This may be any reasonable URL format and is rebuilt at the client to go to the correct place.  Relative, off-host, and queries are detected and processed properly

  • force
    If this variable exists and is true, the result will be returned and displayed on the client, even if it's not matched by the search engine.  

Return to Documentation Home I Return to Sangoma Support