Page 1 of 1

Has anyone ever succeeded setting up a Google Custom Search

Posted: Wed Apr 21, 2010 12:10 pm
by Yvan B
Hey !

I've tried the GCS module, but couldn't make it work. Then I tried a Google Custom Search Engine and it works fine, but not when I use the iframe version (where you can set to show the results of queries in one of your own pages).

I've done exactly what was asked but it just won't work. Has anyone managed to make this work on his own CMSMS ?

Details:

Code I've put instead of the classic search bar:


   
   
   
   
   


Then in the meta of the page:

{literal}

  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 600;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";


{/literal}

and in the content of the page:

Votre recherche est en cours...

I've tried different adress for the results to appear, but I'm always redirect to the default page. I've then set the result to appear there, but it didn't even work.

Re: Has anyone ever succeeded setting up a Google Custom Search Engine ?

Posted: Thu Apr 22, 2010 1:00 am
by viebig
can you show us a url?

regards

Re: Has anyone ever succeeded setting up a Google Custom Search Engine ?

Posted: Thu Apr 22, 2010 2:19 pm
by Yvan B
Sure I can : http://www.coord21.ch/test_cmsms

So, you better check the search option from the main page ('Accueil'). The results are meant to be shown in the last page of the menu ('Résultat de recherche'). I can't see what's wrong in this configuration.

Thanks for your interest. I hope you can spot the problem. Cheers

Re: Has anyone ever succeeded setting up a Google Custom Search Engine ?

Posted: Thu Apr 22, 2010 5:12 pm
by scooper
I've certainly used Google Custom Search on a few sites, but always with pretty URLs enabled. 
Looking at your site it's possible that because the form is using GET rather POST then the URI is getting confused.

If you can enable pretty URLs that that would certainly be worth doing.

Otherwise you could try adding a method="post" to your form tag which should get you to the right page but I'm not sure whether the iFrame will know what's going on.

So:

Code: Select all


<div id="search">
      
    <form action="http://www.coord21.ch/test_cmsms/index.php?page=recherche" id="cse-search-box" method="post">
    <input name="cx" value="005584578441396243232:epked-4geyy" type="hidden">
    <input name="cof" value="FORID:10" type="hidden">
    <input name="ie" value="UTF-8" type="hidden">
    <input style="border: 1px solid rgb(126, 157, 185); padding: 2px; background: url("http://www.google.com/cse/intl/fr/images/google_custom_search_watermark.gif") no-repeat scroll left center rgb(255, 255, 255);" name="q" size="31" type="text">
    <input name="sa" value="Rechercher" type="submit">
    <input value="www.coord21.ch/test_cmsms/index.php?page=recherche" name="siteurl" type="hidden"></form>

</div>

s.

Re: Has anyone ever succeeded setting up a Google Custom Sea

Posted: Fri Apr 23, 2010 9:38 am
by Yvan B
Thanks !

I changed for pretty URLs and I'm now redirected to the right place. The form you showed me works the same than the one Google provides. The siteurl input you added doesn't replace the other, it just adds another variable to the url:

http://www.coord21.ch/test_cmsms/recher ... Frecherche

Anyway, I don't get why it doesn't show anything.
I'm trying something else atm, but if you can find a reason why it wouldn't show anything, I'd be very happy :). Cheers

EDIT: The other way worked out, so I think I'll stick with it.

In the head of my main template:

{literal}

     
    function inputFocus() {
        document.getElementById('query-input').style['background'] = '';
      }

      function inputBlur() {
        var queryInput = document.getElementById('query-input');
        if (!queryInput.value) {
          queryInput.style['background'] = 'white url(http://www.google.com/coop/images/googl ... ermark.gif) no-repeat 0% 50%';
        }
      }
   
{/literal}

For the search bar:

   
     
     
   

In the page:

{literal}

   
      google.load('search', '1');

      function getQuery() {
        var url = '' + window.location;
        var queryStart = url.indexOf('?') + 1;
        if (queryStart > 0) {
          var parts = url.substr(queryStart).split('&');
          for (var i = 0; i
{/literal}

The sad thing is that I can't use the styling of my custom search engine. Too bad...