Thursday, October 15, 2009

Search Plugin

Ok,
having finished a first pass at the component so search for 'Author' type users, i now want to search for that authors content when the user selects one of those Authors.

Best way seems to be a search plugin.

So, starting point is here. More to follow as i develop it.

Update #1 - Implementation
All we need to do is create an XML descriptor (authorcontent.xml) and a Php file to perform the search (authorcontent.php).

Update #2 - Using It
Ok, creating the search plugin is simple as detailed here.

Having developed the plugin we need to trigger it and use the results.

A sample of using it can be found in the standard search component (com_search/models/search.php).

Using it will be something like:


JPluginHelper::importPlugin( 'search');
$dispatcher =& JDispatcher::getInstance();
$results = $dispatcher->trigger( 'onSearch', array(
$rows = array();
foreach($results AS $result) {
$rows = array_merge( (array) $rows, (array) $result);
}

No comments: