Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

How to embed google into search bar (also, why is my latest post not showing up?)

edited February 2012 in Vanilla 2.0 - 2.8

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&quot; 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

  • Options
    x00x00 MVP
    edited February 2012

    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.

  • Options
    mcu_hqmcu_hq yippie ki-yay ✭✭✭

    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.

Sign In or Register to comment.