Google AJAX search API integration (2 posts)

  1. ADBL
    Posted 5 years ago #

    Hi --

    I'm trying to use this:

    I'm planning to use single_post_title (of a page in this case) to display tabbed search result like this one:
    in a sidebar, or within the page itself, prefilled with the post title.

    Has anyone played with this already? Is there a plugin for this?

    The closest I have found is this:

    But as far as I can tell, it's limited to blog/web search, and more abou adding a search box; I don't need the search box, just search results; plus I need image search and news.

    I'll post back here when I get somewhere with this.

  2. ADBL
    Posted 5 years ago #

    Just in case...

    I subscribed to get an API key

    Then I struggled a little bit, from the "Hello World" example they give, and came up with this:

    <div id="gajax">
    			   <script src="http://www.google.com/jsapi?key=MY-KEY-XXXXXXXXXX"></script>
        <script language="Javascript" type="text/javascript">
          google.load('search', '1.0');
          function OnLoad() {
            // create a tabbed mode search control
            var tabbed = new google.search.SearchControl();
    			tabbed.addSearcher(new google.search.VideoSearch());
     			tabbed.addSearcher(new google.search.WebSearch());
    			tabbed.addSearcher(new google.search.NewsSearch());
    			tabbed.addSearcher(new google.search.ImageSearch());
            // draw in tabbed layout mode
            var drawOptions = new google.search.DrawOptions();
            tabbed.draw(document.getElementById("search_control_tabbed"), drawOptions);
            tabbed.execute("<?php the_title(); ?>");
          google.setOnLoadCallback(OnLoad, true);
        <div style="float: right;" class="search-control" id="search_control_tabbed">Loading</div>

    In a custom NextGen gallry template (gallery-gs.php) that I can call with "template=gs" as a parameter to my gallery tag.

    This can be used within a page or post template I guess.

    ...which displays something close to this:
    With different search options, that I display kinda like a sidebar to my gallery, based on the page title (an actor name in this case).

    I'm still struggling with styling; didn't really get how you overwrite Google's default css styling.

    Also I wanted to hide the search box, and found this:

    ...but I couldn't really find where/how to throw these lines into the above code without breaking the whole thing.

Topic Closed

This topic has been closed to new replies.

About this Topic