ctwise Posted January 29, 2013 Share Posted January 29, 2013 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}"); $xml = simplexml_load_file("http://google.com/complete/search?output=toolbar&q=$text"); 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
jdfwarrior Posted January 29, 2013 Share Posted January 29, 2013 Will be fixed. I've already been cleaning it up and making it work a little better. Will be released soon. jibbe 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now