• 3 odgovora
  • 3.475 pregleda
Google custom search engine problem 25.05.2008. u 10:59 · pre 224 meseci #1
Imam problem sa funkcionalnoscu Google Custom Search Engine-a, tj. za bilo koju rec koju mu zadam da pretrazuje ne moze da pronadje rezultat u okviru mog sajta i to za neke reci koje se pojavljuju na svakoj stranici. Evo koda koji sam koristio

stranica na kojoj je forma
Code:

<form action="http://mojsajt.com/result.html" id="cse-search-box">
  <div>
    <input type="hidden" name="cx" value="007534734189520848532:pk6wzzehmis" />
    <input type="hidden" name="cof" value="FORID:11" />
    <input type="text" name="q" size="25" />
    <input type="submit" name="sa" value="Search" />
  </div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse...orm=cse-search-box&lang=en"></script>


stranica na kojoj se prikazuje rezultat
Code:

<div id="cse-search-results"></div>
<script type="text/javascript">
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 600;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>


Ne znam sta moze biti problem

[Ovu poruku je menjao Aleksandar Ružičić dana 25.05.2008. u 17:40 GMT+1]
Potpis
Do not try to bend the spoon, that's impossible.
Instead just try to realize the truth.
What truth?
There is no spoon.
There is no spoon?
Then you'll see that is not the spoon that bends, it is only yourself.
Re: Google custom search engine problem 25.05.2008. u 16:47 · pre 224 meseci #2
jesi li namerno stavio ... u src parametru?
Code:

<script type="text/javascript" src="http://www.google.com/coop/cse...orm=cse-search-box&lang=en"></script>


http://www.google.com/coop/docs/cse/cref.html
Potpis
rafforum.rs - Forum Računarskog Fakulteta
Re: Google custom search engine problem 25.05.2008. u 17:16 · pre 224 meseci #3
Samo sam kopirao ceo kod iz control panela koji je tamo generisan
Potpis
Do not try to bend the spoon, that's impossible.
Instead just try to realize the truth.
What truth?
There is no spoon.
There is no spoon?
Then you'll see that is not the spoon that bends, it is only yourself.
Re: Google custom search engine problem 25.05.2008. u 19:05 · pre 224 meseci #4
Skoro sam se mucio sa slicnom stvari google AJAX search API + jQiery autosuggest.
Ovo je primer bez suggesta:

index.html/php
Code:

<h2>Search:</h2>
<form action="index2.php" method="get">
<input type="text" name="ime" id="ime" />
<input type="submit" value="Submit" />
</form>


index2.php u head deo (naravno moras generisati svoj kljuc
Code:

 <script src="http://www.google.com/jsapi?ke...whTiduBnqm9dVHmRaZsiFp4st_-gLQ" type="text/javascript"></script>
    <script language="Javascript" type="text/javascript">
    //<![CDATA[

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

    function OnLoad() {
      // Create a search control
      var searchControl = new google.search.SearchControl();

      // Add in a full set of searchers
      var localSearch = new google.search.LocalSearch();
    
      searchControl.addSearcher(new google.search.WebSearch()
            
            );
            
            options = new GsearcherOptions();
options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
searchControl.addSearcher(new GwebSearch(), options);

      // Set the Local Search center point
      localSearch.setCenterPoint("New York, NY");

      // Tell the searcher to draw itself and tell it where to attach
      searchControl.draw(document.getElementById("searchcontrol"));

      // Execute an inital search
      //searchControl.execute("Google");
var q = gup("ime"); // gup is function name to get parameter 
if(q) { 
  searchControl.execute(q); 

}
    }
    google.setOnLoadCallback(OnLoad);
        

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
    //]]>
    </script>


Code:

   <div id="searchcontrol">Loading...</div>
</div>

Kontejner u kom ce se rezultat prikazivati.

Po mom kodu po defaultu se siri (expand) web search ne local search,
ali to ces lako prepraviti.
Kada u search box upises zeljenu kljucnu rec pretrazivanja otvori ce ti se nova strana
u kojoj ce se naci rezultati.
Ako ne kapiras vici :)
Potpis
Tony Melendez:
http://video.google.com/videoplay?docid=-
3819862628517136815&q=tony+melendez

NIKADA NE UZIMATI HOSTING NA GO DADDY!


Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme