Author Topic: How to Easily replace the smf theme default search with google custom search  (Read 1095 times)

0 Members and 1 Guest are viewing this topic.

gadgetwinch

  • Guest
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

precious

  • Guest
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

Offline obasimiracle

  • Support Expert
  • *****
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?
Wisdom pays! Be wise!

precious

  • Guest
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

Offline obasimiracle

  • Support Expert
  • *****

Thanks for notifyin me bro,but what is d situation cos its openin fine from this end on all my browser
it's fine already
Wisdom pays! Be wise!

Offline obasimiracle

  • Support Expert
  • *****
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: [Select]
'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: [Select]
<?php require("/home/*******/public_html/SSI.php"); 
$context['page_title_html_safe'] = 'Results';
template_header(); 
echo
'
<br />


<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: [Select]
home/*******/public_html/SSI.phpwith your full forum path

Now edit your current theme  index.template.php and search for this
Code: [Select]
<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" />&nbsp;
<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: [Select]
<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: [Select]
http://www.simplemachines.org/community/index.php?topic=366910.0if your smf version is different from the one in this tutorial
« Last Edit: December 30, 2012, 09:04:24 AM by obasimiracle »
Wisdom pays! Be wise!

precious

  • Guest
Thanks bro for the detailed tutorial am gonna try it out now

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Note: this post will not display until it's been approved by a moderator.
Name: Email:

Inside: 3P Techies Blog

* Newest Techies

Get Updates


Sign up to get latest updates delivered to your inbox. No Spam, We Promise!

Get Hosting!

a Faster web hosting service

Copyright 3rd Planet Techies. All rights Reserved.

Top || Mobile ||Advertise || Contact Us || Privacy