StudioPress Community Forums
  StudioPress Community Forums > Forums > General Discussion
For help and support, access to your downloads, or to manage your account please log into My StudioPress.

These forums have been set to read-only so you can browse the existing topics for any questions you may have -- and this forum will be removed on July 1st, 2013.

For general discussion on WordPress, CSS and design (NOT for support) visit the new Community Forums.
 
 
Thread Tools Display Modes
  #1  
Old 07-19-2012, 09:23 PM
protechig protechig is offline
Registered User
Genesis Member
Pro Plus Member
 
Join Date: Feb 2012
Location: Philadelphia
Posts: 155
Default Add Google Two Page Custom Search

Hello,
I'm having huge issues with Google Custom Search:
Search Code added to page (www.networkthroughput.com/google-bar)
PHP Code:
<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 Code:
<?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(); ?>
After doing all of this, it still doesn't work, what am I dong wrong?
  #2  
Old 07-23-2012, 09:47 AM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

This level of coding is beyond the scope of the support we are able to provide in the forum, as it requires custom code to be written and tested, but I will leave this thread open in case a community member is able/willing to assist you.
__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

  #3  
Old 07-23-2012, 12:32 PM
protechig protechig is offline
Registered User
Genesis Member
Pro Plus Member
 
Join Date: Feb 2012
Location: Philadelphia
Posts: 155
Default

Okay,

Thank you
  #4  
Old 07-27-2012, 05:01 AM
dusdatja dusdatja is offline
Registered User
Genesis Member
 
Join Date: Jul 2012
Posts: 17
Default

I have been testing this on my own site and I have the same problems. While I was copying en pasting code I did managed to get it to work without opening a HTML editor. So it is possible without advanced customization. Problem is I deleted the code, so it isn't working anymore.

Strange thing is, code provides two types of codes. One pair with one div and a script for the search widget. And another one that you implement on the search result page like www.domain.com/search. Stragen thing is that it is not working
  #5  
Old 07-28-2012, 01:21 PM
protechig protechig is offline
Registered User
Genesis Member
Pro Plus Member
 
Join Date: Feb 2012
Location: Philadelphia
Posts: 155
Default

Yea, did you end up finding a solution?
  #6  
Old 10-17-2012, 08:14 PM
mattvaden's Avatar
mattvaden mattvaden is offline
Registered User
Genesis Member
 
Join Date: Jul 2012
Location: Mississippi
Posts: 6
Thumbs up Possible Solution

Hello all,
I was reading through the forum over the last couple of days... and I saw this thread. Just wanted to let you guys know that I had just recently set this up and it is actually rather easy! Here is the link to the post that I used for instructions: How-to-add-Google-Custom-Search

P.S. If this helps you, please pass it along.

Cheers,
Matt

Last edited by mattvaden; 10-17-2012 at 08:14 PM. Reason: Mis-spelling
  #7  
Old 10-17-2012, 08:29 PM
mattvaden's Avatar
mattvaden mattvaden is offline
Registered User
Genesis Member
 
Join Date: Jul 2012
Location: Mississippi
Posts: 6
Smile Oops, I forgot to mention:

In Step 1 of the tutorial I shared, you will notice a screenshot that shows where you can choose between "Open Results on Google in the same window" or "Open results within my own site". I chose the later.

#1. I went to my site, created a WordPress "Page" titled "Search Results (slug is search-results)

#2. I followed the instructions in the tutorial I linked to earlier.

#3. I inserted the following Google code into a "Text Widget" in my sidebar:
Code:
<form action="http://www.mattsaffiliatejourney.com/search-results/" id="cse-search-box">
  <div>
    <input type="hidden" name="cx" value="partner-pub-<code removed here>" />
    <input type="hidden" name="cof" value="FORID:10" />
    <input type="hidden" name="ie" value="UTF-8" />
    <input type="text" name="q" size="25" />
    <input type="submit" name="sa" value="Go" />
  </div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>
#4. I inserted the following code and text into my search-results page:
Code:
<strong>Note:</strong> To see the search results from my site, please read below the Google ads! Cheers!<br />
<div id="cse-search-results"></div>
<script type="text/javascript">
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 800;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
Note: Do NOT use the exact code I listed above in step #3, because it will search my site! You MUST use the code that Google provides for you so that it will have your unique "Partner ID" in the code. I have provided this code so that you would be able to see an example of what the code looks like.

#5. Also make sure you choose the "iframe" option on Google. This will make the "two page search results" option work properly. Note: Google says that the iframe option has been deprecated, but it still works for now. I was unable to get the new "V1" or "V2" code for the "two page results" settings to work. Just stick to the tutorial (exactly step for step) for now, and if something changes or the search box with an iframe option stops working, I will come back here and update this thread with any changes that may need to be made.

You can see the Google Custom Search box in action here: Matt's Affiliate Journey
__________________
Regards,
Matt Vaden

Last edited by mattvaden; 10-17-2012 at 08:36 PM. Reason: Added Step #5.
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lijit vs. WP search vs. Google Custom search Jeff Hester General Discussion 1 05-14-2010 10:38 AM


All times are GMT -5. The time now is 02:57 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.