Jump to content

Small issue with Google Search workflow


Recommended Posts

The Google Search workflow is awesome but has one small issue - if there are no search suggestions it ends up searching google for 'g {query}' instead of just '{query}'. It can be remedied with one small change to the script filter, adding an item to the suggestion list if no suggestions were found, e.g.:

 

 

require_once('extension_utils.php');
$utils = new ExtensionUtils();
 
$results = array();
$text = urlencode("{query}");
 
foreach( $xml as $sugg ):
$item = array(
'uid' => 'suggest {query}',
'arg' => $sugg->suggestion->attributes()->data,
'title' => ucwords($sugg->suggestion->attributes()->data),
'subtitle' => 'Search Google for '. $sugg->suggestion->attributes()->data,
'icon' => 'icon.png',
'valid' => 'yes'
);
array_push( $results, $item );
endforeach;
if ( count($results) == 0 ):
$item = array(
'uid' => 'suggest {query}',
'arg' => '{query}',
'title' => '{query}',
'subtitle' => 'Search Google for '. '{query}',
'icon' => 'icon.png',
'valid' => 'yes'
);
array_push( $results, $item);
endif;
 
if ( count( $results ) > 0 ):
echo $utils->arrayToXml( $results );
endif;
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...