How to embed google into search bar (also, why is my latest post not showing up?)
I've made a post regarding embedding google into the search bar here:
luc said: And if you're using a Smarty Theme (ie .tpl), you need to put this in library/vendors/SmartyPlugins/function.searchbox.php , and just change the main div in the template
I would like to add google custom search through the embedded theme's search box. So...In the above file, do I replace it's contents:
function smarty_function_searchbox($Params, &$Smarty) { $Form = Gdn::Factory('Form'); $Form->InputPrefix = ''; $Result = $Form->Open(array('action' => Url('/search'), 'method' => 'get')). $Form->TextBox('Search', array('placeholder' => T('Search'))). $Form->Button('Go', array('Name' => '')). $Form->Close(); return $Result; }
with the code tjforsythe mentioned?
<div class="Google-Search">Google Search</div> <div id="cse" style="width: 100%;">Loading</div> <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript"> google.load('search', '1', {language : 'en', style : google.loader.themes.SHINY}); google.setOnLoadCallback(function() { var customSearchControl = new google.search.CustomSearchControl('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); customSearchControl.draw('cse'); }, true); </script> </div>
Then, what do I do regarding "changing the main div in the template"?
I could use the Vanoogle plugin, but I do not want a floating search box. I would like it to use the templates search box.
Also, I posted this on the end of an old thread but it didn't 'resurface'....it did not make its way to to the top of the comment 'queue'.
http://vanillaforums.org/discussion/comment/154697#Comment_154697
Thanks for the help!
Comments
You can style the Vangogle to be pretty much identical to the searchbox.
It is a question of using lots of
!important
, to override google default styling.If you want dedicate google search you have to pay google.
grep is your friend.
If you really want a good search engine and you have access to your server, I would recommend sphinx search engine. I was thinking about implementing this myself in the near future. I have had wonderful success with it in the past and can't recommend it enough.