What's new

How to Easily replace the smf theme default search with google custom search

  • Thread starter gadgetwinch
  • Start date
  • Viewed 2676 times.
G

gadgetwinch

I want to be able to use google custom search on my smf site running on smf 2.0.3 "white box" theme as well as remove the "search" and "help"  button close to  Home on the navigation tab .

I have already registered on google already
 
Exactly what i want to  do on my blog.I have generated the google search custom code but on placing it inside the html/javascrip blogger gadget ,it doesnt work

any useful help will be highly appreciated
 
precious said:
Exactly what i want to  do on my blog.I have generated the google search custom code but on placing it inside the html/javascrip blogger gadget ,it doesnt work

any useful help will be highly appreciated
your blog isn't opening fine why?
 
obasimiracle said:
precious said:
Exactly what i want to  do on my blog.I have generated the google search custom code but on placing it inside the html/javascrip blogger gadget ,it doesnt work

any useful help will be highly appreciated
your blog isn't opening fine why?

Thanks for notifyin me bro,but what is d situation cos its openin fine from this end on all my browser
 
gadgetwinch said:
I want to be able to use google custom search on my smf site running on smf 2.0.3 "white box" theme as well as remove the "search" and "help"  button close to  Home on the navigation tab .

I have already registered on google already
Using google custom search /adsense shouldn't be a headache for newbies as there is already a mod for this all you need do is download the mod from here same for removing help from menu you can just download the remove help from menu mod here, except you wanna do some little customization yourself which is just as easy as installing new mod .

Now to manually remove help and search from smf navigation tab so as to display only your google custom search all you need do is => log in to cpanel /your forum / sources /subs.php and
search for this
Code:
'help' => array(
				'title' => $txt['help'],
				'href' => $scripturl . '?action=help',
				'show' => true,
				'sub_buttons' => array(
				),
			),
above or below it you will see search just change the true to false in both of them to have them hidden or mark them off to delete them completely .

Now to Replace your theme default search bar on smf 2.0.3 with google custom search all you need do is take note of the width in your theme css so as to know the options to configure in your custom search button options .

Now first step is to open your notepad and save it as results.php then go to your google adsense account and click on search (adsense for search) from "my ads" tab then from there create a new search custom search engine , give it a name and choose only Sites I select =>> Inside the list of sites enter your forum url starting with http://=>>on search box style remember to choose the width equal to the size of your forum search or edit your forum theme css to equal that of the width size you 've chosen ==>on search result choose "on my site using an iframe" then enter your forumurl/results.php under where search results will be displayed with width that will fit your forum theme (maybe 790).==> save and get code.

From the two code provided locate the one for result and paste it in the results.php you 've already created with your notepad or simply select and paste this
Code:
 <?php require("/home/*******/public_html/SSI.php"); 
$context['page_title_html_safe'] = 'Results';
template_header(); 
echo'




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

</center></td>
        </tr>
    </tbody>
</table>';

template_footer(); ?>
save and upload it to the root directory of your forum where you have ssi.php

n/b replace
Code:
home/*******/public_html/SSI.php
with your full forum path

Now edit your current theme  index.template.php and search for this
Code:
				<div class="news normaltext">
				<form id="search_form" style="margin: 0;" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
					<input type="text" name="search" value="" class="input_text" /> 
					<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
					<input type="hidden" name="advanced" value="0" />';
and replace it with the code google provided you as in :
Code:
<div class="news normaltext">
<form action="http://www.obasimvilla.com/forum/results.php" id="cse-search-box">
  <div>
	 <input type="hidden" name="cx" value="partner-pub-0022808160619558:cah4ko-n5ph" />
	 <input type="hidden" name="cof" value="FORID:10" />
	 <input type="hidden" name="ie" value="ISO-8859-1" />
	 <input type="text" name="q" size="31" />
  </div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>';

save and reload your forum to check if every thing now works fine .

you may refer to a more pragmatic tutorial in the smf official site here
Code:
http://www.simplemachines.org/community/index.php?topic=366910.0
if your smf version is different from the one in this tutorial
 
Top