WordPress.org

Ready to get started?Download WordPress

Forums

Add Two Page Google Custom Search To Theme (4 posts)

  1. Zach Russell
    Member
    Posted 2 years ago #

    Hello,
    I'm having huge issues with Google Custom Search:

    It's on a theme currently running on the genesis framework, but I also tried it on the twenty-eleven theme, with no success. Basically all I want to do is have a search bar at the top of every page (currently in a header-right sidebar), and then have the results on a separate page, almost mimicking the google search.

    Search Code added to page (www.networkthroughput.com/google-bar)

    <div id="cse-search-form" 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'});
      google.setOnLoadCallback(function() {
        var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
          '010002822605264734718:WMX1063238125', customSearchOptions);
        customSearchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
        var options = new google.search.DrawOptions();
        options.setAutoComplete(true);
        options.enableSearchboxOnly("http:\x2F\x2Fwww.networkthroughput.com\x2Fresults", "");
        customSearchControl.draw('cse-search-form', options);
      }, true);
    </script>
    <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
    <style type="text/css">
      input.gsc-input {
        border-color: #BCCDF0;
      }
      input.gsc-search-button {
        border-color: #CECECE;
        background-color: #E9E9E9;
      }</style>

    I then Created a search.php:

    <?php get_header(); ?> 
    
        <div id="home"> 
    
        <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'});
      google.setOnLoadCallback(function() {
        var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
          '010002822605264734718:WMX1063238125', customSearchOptions);
        customSearchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
        var options = new google.search.DrawOptions();
        options.setAutoComplete(true);
        customSearchControl.draw('cse', options);
        function parseParamsFromUrl() {
          var params = {};
          var parts = window.location.search.substr(1).split('\x26');
          for (var i = 0; i < parts.length; i++) {
            var keyValuePair = parts[i].split('=');
            var key = decodeURIComponent(keyValuePair[0]);
            params[key] = keyValuePair[1] ?
                decodeURIComponent(keyValuePair[1].replace(/\+/g, ' ')) :
                keyValuePair[1];
          }
          return params;
        } 
    
        var urlParams = parseParamsFromUrl();
        var queryParamName = "q";
        if (urlParams[queryParamName]) {
          customSearchControl.execute(urlParams[queryParamName]);
        }
      }, true);
    </script>
    <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
    <style type="text/css">
      .gsc-control-cse {
        font-family: Arial, sans-serif;
        border-color: #FFFFFF;
        background-color: #FFFFFF;
      }
      .gsc-control-cse .gsc-table-result {
        font-family: Arial, sans-serif;
      }
      input.gsc-input {
        border-color: #BCCDF0;
      }
      input.gsc-search-button {
        border-color: #CECECE;
        background-color: #E9E9E9;
      }
      .gsc-tabHeader.gsc-tabhInactive {
        border-color: #E9E9E9;
        background-color: #E9E9E9;
      }
      .gsc-tabHeader.gsc-tabhActive {
        border-top-color: #FF9900;
        border-left-color: #E9E9E9;
        border-right-color: #E9E9E9;
        background-color: #FFFFFF;
      }
      .gsc-tabsArea {
        border-color: #E9E9E9;
      }
      .gsc-webResult.gsc-result,
      .gsc-results .gsc-imageResult {
        border-color: #FFFFFF;
        background-color: #FFFFFF;
      }
      .gsc-webResult.gsc-result:hover,
      .gsc-imageResult:hover {
        border-color: #FFFFFF;
        background-color: #FFFFFF;
      }
      .gsc-webResult.gsc-result.gsc-promotion:hover {
        border-color: #FFFFFF;
        background-color: #FFFFFF;
      }
      .gs-webResult.gs-result a.gs-title:link,
      .gs-webResult.gs-result a.gs-title:link b,
      .gs-imageResult a.gs-title:link,
      .gs-imageResult a.gs-title:link b {
        color: #0000CC;
      }
      .gs-webResult.gs-result a.gs-title:visited,
      .gs-webResult.gs-result a.gs-title:visited b,
      .gs-imageResult a.gs-title:visited,
      .gs-imageResult a.gs-title:visited b {
        color: #0000CC;
      }
      .gs-webResult.gs-result a.gs-title:hover,
      .gs-webResult.gs-result a.gs-title:hover b,
      .gs-imageResult a.gs-title:hover,
      .gs-imageResult a.gs-title:hover b {
        color: #0000CC;
      }
      .gs-webResult.gs-result a.gs-title:active,
      .gs-webResult.gs-result a.gs-title:active b,
      .gs-imageResult a.gs-title:active,
      .gs-imageResult a.gs-title:active b {
        color: #0000CC;
      }
      .gsc-cursor-page {
        color: #0000CC;
      }
      a.gsc-trailing-more-results:link {
        color: #0000CC;
      }
      .gs-webResult .gs-snippet,
      .gs-imageResult .gs-snippet,
      .gs-fileFormatType {
        color: #000000;
      }
      .gs-webResult div.gs-visibleUrl,
      .gs-imageResult div.gs-visibleUrl {
        color: #008000;
      }
      .gs-webResult div.gs-visibleUrl-short {
        color: #008000;
      }
      .gs-webResult div.gs-visibleUrl-short {
        display: none;
      }
      .gs-webResult div.gs-visibleUrl-long {
        display: block;
      }
      .gs-promotion div.gs-visibleUrl-short {
        display: none;
      }
      .gs-promotion div.gs-visibleUrl-long {
        display: block;
      }
      .gsc-cursor-box {
        border-color: #FFFFFF;
      }
      .gsc-results .gsc-cursor-box .gsc-cursor-page {
        border-color: #E9E9E9;
        background-color: #FFFFFF;
        color: #0000CC;
      }
      .gsc-results .gsc-cursor-box .gsc-cursor-current-page {
        border-color: #FF9900;
        background-color: #FFFFFF;
        color: #0000CC;
      }
      .gsc-webResult.gsc-result.gsc-promotion {
        border-color: #336699;
        background-color: #FFFFFF;
      }
      .gsc-completion-title {
        color: #0000CC;
      }
      .gsc-completion-snippet {
        color: #000000;
      }
      .gs-promotion a.gs-title:link,
      .gs-promotion a.gs-title:link *,
      .gs-promotion .gs-snippet a:link {
        color: #0000CC;
      }
      .gs-promotion a.gs-title:visited,
      .gs-promotion a.gs-title:visited *,
      .gs-promotion .gs-snippet a:visited {
        color: #0000CC;
      }
      .gs-promotion a.gs-title:hover,
      .gs-promotion a.gs-title:hover *,
      .gs-promotion .gs-snippet a:hover {
        color: #0000CC;
      }
      .gs-promotion a.gs-title:active,
      .gs-promotion a.gs-title:active *,
      .gs-promotion .gs-snippet a:active {
        color: #0000CC;
      }
      .gs-promotion .gs-snippet,
      .gs-promotion .gs-title .gs-promotion-title-right,
      .gs-promotion .gs-title .gs-promotion-title-right *  {
        color: #000000;
      }
      .gs-promotion .gs-visibleUrl,
      .gs-promotion .gs-visibleUrl-short {
        color: #008000;
      }</style> 
    
    </div><!-- end #home --> 
    
    <?php get_footer(); ?>
  2. Zach Russell
    Member
    Posted 2 years ago #

    Any Ideas why I cannot Get this working?

  3. Krishna
    Volunteer Moderator
    Posted 2 years ago #

    Genesis Framework has special boxes for inserting codes. Look for them in the Framework options/ setup. If you do not find them or if it does not work, please contact the theme vendor because it is a commercial theme.

  4. Zach Russell
    Member
    Posted 2 years ago #

    I understand your point, but that is not the issue that I am experiencing, If I switch to any (non-premium) theme, such as twentyeleven, it still does not work. This is not a Genesis issue, if it was i'd be asking for support in their forums. I'd appreciate any more help you could give me on this.

    Zach

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.