Fork me on GitHub
Current releases are 2.1.1 (2 Aug 2014) and 2.0.18.13 (5 Aug 2014)
Ready for 2.1? Find out if your favorite plugins are compatible.
The 2.0 branch will no longer receive updates after Dec 2014.

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

ntuyelikntuyelik New
edited March 2011 in Vanilla 2.0 Help
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
  • ddumontddumont ✭✭
    edited September 2011
  • @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 ****!

Sign In or Register to comment.