Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: dischord - tammikuu 21, 2006, 06:19:59 AP

Otsikko: Google AdSense for Search integration?
Kirjoitti: dischord - tammikuu 21, 2006, 06:19:59 AP
Sorry if this has been posted before. I can find similiar things, but not quite what I want.

It's a bit like this
http://www.simplemachines.org/community/index.php?topic=46648.msg337817#msg337817 (http://www.simplemachines.org/community/index.php?topic=46648.msg337817#msg337817)

and a bit like this
http://www.simplemachines.org/community/index.php?topic=47313.msg338099#msg338099 (http://www.simplemachines.org/community/index.php?topic=47313.msg338099#msg338099)

Since I already have an account for adsense, I thought I might integrate it into the search code. I don't want to completely replace the search form with the google form, and I need the browser to send some headers with the search request as well, so header('Location: http://www.google.com/search... won't work.

So, I need this code...
<!-- SiteSearch Google -->
<form method="get" action="http://www.google.com/custom" target="_top">
    <input type="hidden" name="domains" value="www.some_site.com"></input>
    <input type="text" name="q" size="31" maxlength="255" value=""></input>
    <input type="submit" name="sa" value="Search"></input>

    <input type="radio" name="sitesearch" value="www.some_site.com"></input>
    <font size="-1" color="#000000">Entire site</font>           

    <input type="radio" name="sitesearch" value="" checked="checked"></input>
    <font size="-1" color="#000000">Message board</font>

    <input type="hidden" name="client" value="pub-xxxxxxxxxxxxxxxx"></input>
    <input type="hidden" name="forid" value="1"></input>
    <input type="hidden" name="ie" value="ISO-8859-1"></input>
    <input type="hidden" name="oe" value="ISO-8859-1"></input>
    <input type="hidden" name="cof" value="GALT:#..snip.."></input>
    <input type="hidden" name="hl" value="en"></input>
</form>
<!-- SiteSearch Google -->


...somehow added so selecting the first radio button will perform google's search request, and the second radio button will use the standard message board search request without having anything to do with the google search.

Could it be added into the template code?
<form action="', $scripturl, '?action=search2" method="post" style="margin: 0; margin-top: 7px;">
<b>', $txt[182], ': </b><input type="text" name="search" value="" style="width: 190px;" />&nbsp;
<input type="submit" name="submit" value="', $txt[182], '" style="width: 8ex;" />&nbsp;
<a href="', $scripturl, '?action=search;advanced">', $txt['smf298'], '</a>
<input type="hidden" name="advanced" value="0" />';

// If we're on a certain board, limit it to this board ;).
if (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

echo '
</form>


...or would I have to mess with Search.php?

Any help would be appreciated!

Thanks
/Alex
Otsikko: Re: Google AdSense for Search integration?
Kirjoitti: dischord - tammikuu 21, 2006, 11:44:37 AP
Nevermind!! I was being stupid as usual.

Thanks for not replying in this case :P