Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 05:23:08 AM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 52
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 1
Guests: 54
Total: 55

Author Topic: forum/google search block  (Read 15140 times)

0 Members and 1 Guest are viewing this topic.

extacy

  • Guest
forum/google search block
« on: February 27, 2006, 04:32:35 AM »
May need to be moved, sorry....

I have been trying to come up with a search block that does exactly what the one on smf home page does. 1, sends you to a google site search and 2 sends you to a forum search. This is the best I can do with my limited knowledge of html/php etc. You just add this to a script box and change the 2 mysites.com to your own and you should be in business...

***You may need to change the "/forum" so it matches your forums location...***

Code: [Select]
<table border="0" cellspacing="1" style="border-collapse: collapse" width="13%" id="table1" height="105">
<tr>
<td align="left"><tbody><tr><th class="right" align="left">
<p style="margin-top: 0; margin-bottom: 0"><b><font color="#FF0000">Site Search</font></b></th></tr>
<tr>
<td class="right" align="left" valign="top" height="95">
<form style="margin-top: 4px; margin-bottom: 4px;" method="get" name="searchform" action="http://www.google.com/search" target="_top">
<input name="sitesearch" value="www.mysite.com" type="hidden">
<p style="margin-top: 0; margin-bottom: 0">
<input alt="search" style="width: 65px;height:22" name="as_q" size="20" type="text"> <input style="width: 41; font-weight: bold; height:26" value="GO" type="submit">
</p>
</form>

<p style="margin-top: 0; margin-bottom: 0"><b><font color="#FF0000">Forum Search</font></b></p>

<form action="http://www.mysite.com/forum/index.php?action=search2" method="post" target="_top" style="margin-top: 4px; margin-bottom: 4px;" method="get" name="searchform">
<p style="margin-top: 0; margin-bottom: 0">
<input name="search" style="width: 65px;height:22" name="as_q" size="20" type="text"> <input style="width: 42; font-weight: bold; height:26" value="GO" type="submit">
</p>
</form></td>
</tr>
</table>



I'm told it can be done easier with php, but me's don't know how.....

Anyone care to take a stab at it.....


Thanks
X




« Last Edit: February 27, 2006, 09:44:30 AM by extacy »

Mitch

  • Guest
Re: forum/google search block
« Reply #1 on: March 14, 2006, 06:05:17 PM »
Just out of curiousity what is the difference of this and the actual search function?

Besides you can go to google.

extacy

  • Guest
Re: forum/google search block
« Reply #2 on: March 20, 2006, 02:27:28 AM »
Well it searches your forum normally or a google site search.
As the 2 turn out way different results.

The real stupid thing about it is if you go to google adsence and get the code for adding a google site search and your site has not been indexed a whole lot by google,you will be lucky if you get 1 page of results. However if you do it the way laid out here you will get about 10 pages of results and you get credit with google adwords ($) for them doing the search.

The whole thing started out as we were tiring to get the same search as www.simplemachines.com w/ the pull down box and asked around on several forums for help with it. with not much help.... So we came up with our own jerry-rigged version of it..... Because everytime someone searches smf and forgets to pull down the tab to "community" they (smf) get paid from google..... and that's what we are really trying to do with this thing....... However they may be some problems with the way it interacts with adsence.... 


A subject that really should be looked into by the coding gurus as it can help all smf forum owners offset cost.....

I'm told smf does theirs with php...?. :uglystupid2:

thanks
X


eldacar

  • Guest
Re: forum/google search block
« Reply #3 on: March 20, 2006, 02:42:49 AM »
Here's mine:
Put this in a file called search.php
Code: [Select]
<?php

// Search redirector

if ($_REQUEST['where'] == 'entire') {
header('Location: http://www.google.com/search?domains=somedomain.com&sitesearch=somedomain.com&q=' $_REQUEST['q']);
} else {
header('Location: http://somedomain.com/index.php?action=search2;search=' $_REQUEST['q']);
}

?>
And change your TPortalBlocks.template.php search function to:
Code: [Select]
// TPortal searchblock
function TPortal_searchbox()
{
    global $context, $settings, $options, $txt , $scripturl;

echo '<form action="http://somedomain.com/search.php" method="post" style="text-align: center; margin: 0; margin-bottom: 3px;">
<input type="text" name="q" value="" style="width: 85%;" /><br />
<select id="where" name="where" style="width: 42%; margin-top: 2px;" >
<option value="entire">Entire Site</option>
<option value="forum" selected="selected">Forum</option>
</select>
<button type="submit" style="width: 42%; font-size: 85%;">', $txt[182], '</button>
</form>';

}
You can also add other places, I added an option to search my site's wiki.

extacy

  • Guest
Re: forum/google search block
« Reply #4 on: March 20, 2006, 03:11:20 AM »
Hey thanks, I will look at it as soon as I awake... ;)
« Last Edit: March 20, 2006, 03:13:03 AM by extacy »

TwinsX2Dad

  • Guest
Re: forum/google search block
« Reply #5 on: March 20, 2006, 03:28:23 AM »
Here's mine:
Put this in a file called search.php........

Now that is good - cleaner than the one I created. Now I have an extra something else to do.   ;D

ontap

  • Guest
Re: forum/google search block
« Reply #6 on: March 20, 2006, 10:07:19 AM »
i wont ever be using a search box by google! nooooooo way  :tickedoff:

Offline Crip

  • Jesus Inside.
  • Themes
  • *
  • Posts: 4168
  • Theme Support
    • Cripzone
Re: forum/google search block
« Reply #7 on: March 20, 2006, 10:42:39 AM »
OnTap!
you just plain don't like Google do ya.. hehehe :)
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes


TwinsX2Dad

  • Guest
Re: forum/google search block
« Reply #8 on: March 20, 2006, 11:03:53 AM »
i wont ever be using a search box by google! nooooooo way  :tickedoff:

But Google is your friend........ Google is your friend........ Google is your friend........ Google is your friend........ Google is your friend........

Do you hear the utopian tone in that?

I now am seeing Logan's Run flashbacks.......   :coolsmiley:

extacy

  • Guest
Re: forum/google search block
« Reply #9 on: March 20, 2006, 09:20:03 PM »
Quote
Here's mine:
Put this in a file called search.php

Code: [Select]
<?php

// Search redirector

if ($_REQUEST['where'] == 'entire') {
header('Location: http://www.google.com/search?domains=somedomain.com&sitesearch=somedomain.com&q=' $_REQUEST['q']);
} else {
header('Location: http://somedomain.com/index.php?action=search2;search=' $_REQUEST['q']);
}

?>


Hey,
 This really looks great except 1 tiny problem.. No matter where i put this in my search.php it crashes when you do the forum search...

I replaced all the somedomain.com with ours etc...

The google part seems to work fine... I thought perhaps you might want us to make a new search.php with only this in it and i got the same results...   (crash)  Is there somehwere specific we need to put this code in our search.php or is there something else I'm missing?..  :uglystupid2:

This is exactly what I was looking for!!! THX ;)