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.

[2.0.17.8] : How to integrate Google Site Search instead of Vanilla Search?

ntuyelikntuyelik New
edited March 2011 in Vanilla 2.0 - 2.8
I got Google Search code & I'd like to replace vanilla search by google search box.
I added google search box in my forum by using "messages" link in dashboard,but it also gave me results page code.Where should I put the results page code?
Thanks.
Tagged:

Comments

  • You could replace the <div id="Search"> content in your theme's default.master.php with:

    <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>

    and then add a 'Google-Search' styling to your custom.css file to pretty it up. Be sure to replace the hidden google search id with yours.
  • lucluc ✭✭
    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
  • Hello can you be more specific how to add my Google custom search please
  • im using default.master.tpl
  • ddumontddumont ✭✭
    edited September 2011
    is something like vanoogle what you're looking for?
    http://vanillaforums.org/addon/vanoogle-plugin

    There was an error rendering this rich post.

  • @tjforsythe

    where do you find your theme's default.master.php ? mine hasnt got one?

    do you mean dashboard/veiws/master?
  • edited February 2012

    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.

    Thanks for the help!

Sign In or Register to comment.