Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: desai_amogh on April 04, 2014, 10:19:19 AM

Title: how to replace default smf search with google search ??
Post by: desai_amogh on April 04, 2014, 10:19:19 AM
Hi, i need to replace the default SMF search with google search,

how do i do this ??
Title: Re: how to replace default smf search with google search ??
Post by: Matthew K. on April 04, 2014, 10:25:15 AM
Search the modsite: http://custom.simplemachines.org/mods/
Title: Re: how to replace default smf search with google search ??
Post by: desai_amogh on April 04, 2014, 11:16:52 AM
there is none which works with 2.0.7, so i feel im better of editing the template..

can someone help me with editing the template to get google (adsense code) search to replace the default search ??

thanks !
Title: Re: how to replace default smf search with google search ??
Post by: margarett on April 04, 2014, 11:38:50 AM
There is actually just 1 MOD that can do that:
http://custom.simplemachines.org/mods/index.php?mod=2566

Not sure if this is what you want...
Title: Re: how to replace default smf search with google search ??
Post by: Illori on April 04, 2014, 11:45:33 AM
this one should do it as well http://custom.simplemachines.org/mods/index.php?mod=1634 and it adds a few other features. but it does not disable the default search page
Title: Re: how to replace default smf search with google search ??
Post by: desai_amogh on April 07, 2014, 01:50:32 AM
These are good mods if one wants just google search enabled for their forum.

But not good for my purpose.  What I want is, to replace the default search completely by google custom search (AdSense for search (https://support.google.com/adsense/answer/9879?hl=en)) code.

Title: Re: how to replace default smf search with google search ??
Post by: Colin on April 07, 2014, 02:44:22 AM
If it isn't available with the mods currently on the mod site then you can submit a mod request here: http://www.simplemachines.org/community/index.php?board=79.0
Title: Re: how to replace default smf search with google search ??
Post by: desai_amogh on April 07, 2014, 02:47:07 AM
While a mod is being worked upon, IS it possible i can make any changes to the template to achieve this ??
Title: Re: how to replace default smf search with google search ??
Post by: Colin on April 07, 2014, 03:07:26 AM
Sure you can manually modify the index.template.php file if you wish.
Title: Re: how to replace default smf search with google search ??
Post by: desai_amogh on April 07, 2014, 03:55:18 AM
im using the curve theme, and I need to embed the below search box instead of the default one.  Where to put this code ??

<form action="http://www.google.co.in" id="cse-search-box" target="_blank">
  <div>
    <input type="hidden" name="cx" value="partner-pub-xxxxxxxxxxxxx:xxxxxxxxxxxxxx" />
    <input type="hidden" name="ie" value="UTF-8" />
    <input type="text" name="q" size="55" />
    <input type="submit" name="sa" value="Search" />
  </div>
</form>

<script type="text/javascript" src="http://www.google.co.in/coop/cse/brand?form=cse-search-box&amp;lang=en"></script>
Title: Re: how to replace default smf search with google search ??
Post by: swaggaderby on October 20, 2014, 02:49:20 PM
Am in this situation too any way out?
Title: Re: how to replace default smf search with google search ??
Post by: Kindred on October 20, 2014, 04:06:19 PM
http://custom.simplemachines.org/mods/index.php?mod=2566

also ADK had a mod that did google search as well (However, they took all their mods off our site and went to their own site a little while ago)
Title: Re: how to replace default smf search with google search ??
Post by: webewitch on October 31, 2014, 09:01:34 AM
I've just done it.

My coding may not be 'proper' but it works. (Feel free to correct it someone please!)

In Themes/default/index.template.php

about line 274

find this bit:

<div class="news normaltext">
<form id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />&nbsp;
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';

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

echo '</form>';


replace with:
<div class="news normaltext">

';


..and above the ';

insert your google search code :

<div class="news normaltext">
<form action="http://www.google.co.uk" id="cse-search-box" target="_blank">
  <div>
    <input type="hidden" name="cx" value="partner-pub-xxxxxxxx:xxxxxxxxx" />
    <input type="hidden" name="ie" value="UTF-8" />
    <input type="text" name="q" size="55" />
    <input type="submit" name="sa" value="Search" />
  </div>
</form>

<script type="text/javascript" src="http://www.google.co.uk/coop/cse/brand?form=cse-search-box&amp;lang=en"></script>
';


It works for me :
http://www.fuerteventura-forum.com/index.php (http://www.fuerteventura-forum.com/index.php)

I couldn't figure out how to have the results page integrated into my site so I elected for the results on a Google page.

Does anyone know how to implement the integration (one thing deterring me was that the minimum results iframe is 795px - far too wide for my 3 column layout) ?
Title: Re: how to replace default smf search with google search ??
Post by: Kindred on October 31, 2014, 09:56:33 AM
Did you even bother to look at the mod that I linked or check out the ADK site for their version?
Title: Re: how to replace default smf search with google search ??
Post by: webewitch on November 05, 2014, 09:47:17 AM
If you mean me - yes, I looked at the mod but from what I gathered it gives you the option to include Goggle or Yahoo searches.

What I wanted - and did - was to have my own Google Adsense Search - which is different to the standard Google Search - it earns me a little.

I had a quick search for the ADK thing but couldn't find it. I wasn't too bothered as I had already managed.